mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 07:48:37 +01:00
fix members
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import { ProjectModel, TProject } from "@schema/project/ProjectSchema";
|
||||
import { TeamMemberModel } from "@schema/TeamMemberSchema";
|
||||
|
||||
export async function hasAccessToProject(user_id: string, project_id: string, project?: TProject) {
|
||||
export async function hasAccessToProject(user_id: string, project_id: string, email: string, project?: TProject) {
|
||||
const targetProject = project ?? await ProjectModel.findById(project_id, { owner: true });
|
||||
if (!targetProject) return [false, 'NONE'];
|
||||
if (targetProject.owner.toString() === user_id) return [true, 'OWNER'];
|
||||
const isGuest = await TeamMemberModel.exists({ project_id, user_id });
|
||||
const isGuest = await TeamMemberModel.exists({ project_id, $or: [{ user_id }, { email }] });
|
||||
if (isGuest) return [true, 'GUEST'];
|
||||
return [false, 'NONE'];
|
||||
}
|
||||
Reference in New Issue
Block a user