📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
fix: Allow admin-role members to CRUD goals
Blue Mousedede1da8b53e
diff --git a/backend/apps/cloud/src/goal/goal.controller.ts b/backend/apps/cloud/src/goal/goal.controller.tsindex 8e8632a4b..7ccfe44db 100644--- a/backend/apps/cloud/src/goal/goal.controller.ts+++ b/backend/apps/cloud/src/goal/goal.controller.ts@@ -231,12 +231,7 @@ export class GoalController {throw new ForbiddenException('Please, verify your email address first')}- const project = await this.projectService.findOne({- where: {- id: goalDto.pid,- },- relations: ['goals', 'admin'],- })+ const project = await this.projectService.getFullProject(goalDto.pid)if (_isEmpty(project)) {throw new NotFoundException('Project not found')@@ -252,14 +247,14 @@ export class GoalController {where: { project: { id: goalDto.pid } },})- if (user.planCode === PlanCode.none) {+ if (project.admin?.planCode === PlanCode.none) {throw new HttpException('You cannot create new goals due to no active subscription. Please upgrade your account plan to continue.',HttpStatus.PAYMENT_REQUIRED,)}- if (user.isAccountBillingSuspended) {+ if (project.admin?.isAccountBillingSuspended) {throw new HttpException('The account that owns this site is currently suspended, this is because of a billing issue. Please resolve the issue to continue.',HttpStatus.PAYMENT_REQUIRED,diff --git a/backend/apps/cloud/src/goal/goal.service.ts b/backend/apps/cloud/src/goal/goal.service.tsindex ea59c9f52..b785f4548 100644--- a/backend/apps/cloud/src/goal/goal.service.ts+++ b/backend/apps/cloud/src/goal/goal.service.ts@@ -64,7 +64,15 @@ export class GoalService {findOneWithRelations(id: string): Promise<Goal | null> {return this.goalsRepository.findOne({where: { id },- relations: ['project', 'project.admin'],+ relations: [+ 'project',+ 'project.admin',+ 'project.share',+ 'project.share.user',+ 'project.organisation',+ 'project.organisation.members',+ 'project.organisation.members.user',+ ],})}