mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-09 23:48:36 +01:00
fix guest actions
This commit is contained in:
@@ -3,7 +3,7 @@ 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) {
|
||||
export async function getUserProjectFromId(project_id: string, user: AuthContext | undefined, allowGuest: boolean = true) {
|
||||
if (project_id == LITLYX_PROJECT_ID) {
|
||||
const project = await ProjectModel.findOne({ _id: project_id });
|
||||
return project;
|
||||
@@ -11,8 +11,9 @@ export async function getUserProjectFromId(project_id: string, user: AuthContext
|
||||
if (!user?.logged) return;
|
||||
const project = await ProjectModel.findById(project_id);
|
||||
if (!project) return;
|
||||
const hasAccess = await hasAccessToProject(user.id, project_id, project);
|
||||
const [hasAccess, role] = await hasAccessToProject(user.id, project_id, project);
|
||||
if (!hasAccess) return;
|
||||
if (role === 'GUEST' && !allowGuest) return false;
|
||||
return project;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user