mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 07:48:37 +01:00
16 lines
582 B
TypeScript
16 lines
582 B
TypeScript
import { AuthContext } from "./middleware/01-authorization";
|
|
import { ProjectModel } from "~/../shared/schema/ProjectSchema";
|
|
import { LITLYX_PROJECT_ID } from '@data/LITLYX'
|
|
|
|
export async function getUserProjectFromId(project_id: string, user: AuthContext | undefined) {
|
|
if (project_id == LITLYX_PROJECT_ID) {
|
|
const project = await ProjectModel.findOne({ _id: project_id });
|
|
return project;
|
|
} else {
|
|
if (!user?.logged) return;
|
|
const project = await ProjectModel.findOne({ _id: project_id, owner: user.id });
|
|
return project;
|
|
}
|
|
|
|
|
|
} |