diff --git a/packages/cli/src/controllers/project.controller.ts b/packages/cli/src/controllers/project.controller.ts index 3347e97cb7..848ba4b84c 100644 --- a/packages/cli/src/controllers/project.controller.ts +++ b/packages/cli/src/controllers/project.controller.ts @@ -48,7 +48,7 @@ export class ProjectController { @GlobalScope('project:create') // Using admin as all plans that contain projects should allow admins at the very least @Licensed('feat:projectRole:admin') - async createProject(req: ProjectRequest.Create): Promise { + async createProject(req: ProjectRequest.Create) { try { const project = await this.projectsService.createTeamProject(req.body.name, req.user); @@ -57,7 +57,16 @@ export class ProjectController { role: req.user.role, }); - return project; + return { + ...project, + role: 'project:admin', + scopes: [ + ...combineScopes({ + global: this.roleService.getRoleScopes(req.user.role), + project: this.roleService.getRoleScopes('project:admin'), + }), + ], + }; } catch (e) { if (e instanceof TeamProjectOverQuotaError) { throw new BadRequestError(e.message); diff --git a/packages/cli/test/integration/project.api.test.ts b/packages/cli/test/integration/project.api.test.ts index d275362629..0d24912710 100644 --- a/packages/cli/test/integration/project.api.test.ts +++ b/packages/cli/test/integration/project.api.test.ts @@ -29,6 +29,7 @@ import { CacheService } from '@/services/cache/cache.service'; import { mockInstance } from '../shared/mocking'; import { ActiveWorkflowManager } from '@/ActiveWorkflowManager'; import { ProjectRepository } from '@/databases/repositories/project.repository'; +import { RoleService } from '@/services/role.service'; const testServer = utils.setupTestServer({ endpointGroups: ['project'], @@ -394,6 +395,10 @@ describe('POST /projects/', () => { expect(async () => { await findProject(respProject.id); }).not.toThrow(); + expect(resp.body.data.role).toBe('project:admin'); + for (const scope of Container.get(RoleService).getRoleScopes('project:admin')) { + expect(resp.body.data.scopes).toContain(scope); + } }); test('should allow to create a team projects if below the quota', async () => { @@ -871,7 +876,7 @@ describe('DELETE /project/:projectId', () => { { project: otherProject, role: 'workflow:editor' }, ]); await shareWorkflowWithProjects(sharedWorkflow2, [ - { project: otherProject, role: 'workflow:user' }, + { project: otherProject, role: 'workflow:editor' }, ]); // @@ -928,7 +933,7 @@ describe('DELETE /project/:projectId', () => { { project: otherProject, role: 'workflow:editor' }, ]); await shareWorkflowWithProjects(ownedWorkflow2, [ - { project: otherProject, role: 'workflow:user' }, + { project: otherProject, role: 'workflow:editor' }, ]); //