Only display project if current user is project owner
All checks were successful
Lint / lint (20.x) (pull_request) Successful in 4m37s

This commit is contained in:
Adw8 2024-10-30 17:49:51 +05:30
parent 4d123ad33f
commit 7b974b7f6b
2 changed files with 8 additions and 3 deletions

View File

@ -22,8 +22,8 @@ export const createResolvers = async (service: Service): Promise<any> => {
return service.getOrganizationsByUserId(context.user); return service.getOrganizationsByUserId(context.user);
}, },
project: async (_: any, { projectId }: { projectId: string }) => { project: async (_: any, { projectId }: { projectId: string }, context: any) => {
return service.getProjectById(projectId); return service.getProjectById(context.user, projectId);
}, },
projectsInOrganization: async ( projectsInOrganization: async (

View File

@ -407,8 +407,13 @@ export class Service {
return dbOrganizations; return dbOrganizations;
} }
async getProjectById(projectId: string): Promise<Project | null> { async getProjectById(user: User, projectId: string): Promise<Project | null> {
const dbProject = await this.db.getProjectById(projectId); const dbProject = await this.db.getProjectById(projectId);
if (dbProject && dbProject.owner.id !== user.id) {
return null;
}
return dbProject; return dbProject;
} }