mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 07:48:37 +01:00
add members | phase 1
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { AuthContext } from "./middleware/01-authorization";
|
||||
import { ProjectModel } from "~/../shared/schema/ProjectSchema";
|
||||
import { LITLYX_PROJECT_ID } from '@data/LITLYX'
|
||||
import { hasAccessToProject } from "./utils/hasAccessToProject";
|
||||
|
||||
export async function getUserProjectFromId(project_id: string, user: AuthContext | undefined) {
|
||||
if (project_id == LITLYX_PROJECT_ID) {
|
||||
@@ -8,7 +9,10 @@ export async function getUserProjectFromId(project_id: string, user: AuthContext
|
||||
return project;
|
||||
} else {
|
||||
if (!user?.logged) return;
|
||||
const project = await ProjectModel.findOne({ _id: project_id, owner: user.id });
|
||||
const project = await ProjectModel.findById(project_id);
|
||||
if (!project) return;
|
||||
const hasAccess = await hasAccessToProject(user.id, project_id, project);
|
||||
if (!hasAccess) return;
|
||||
return project;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user