📈 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
Change func allowedToManage
kruzhambusb53b7aefb898
diff --git a/src/project/project.controller.ts b/src/project/project.controller.tsindex 17a44579e..28c11e715 100644--- a/src/project/project.controller.ts+++ b/src/project/project.controller.ts@@ -331,9 +331,8 @@ export class ProjectController {throw new NotFoundException()}- if(user.roles[0] === UserType.CUSTOMER) {- this.projectService.allowedToManage(project, uid)- }+ this.projectService.allowedToManage(project, uid, user.roles)+project.active = projectDTO.activeproject.origins = _map(projectDTO.origins, _trim)@@ -401,10 +400,9 @@ export class ProjectController {if (_isEmpty(project)) {throw new NotFoundException(`Project with ID ${id} does not exist`)}-- if(user.roles[0] === UserType.CUSTOMER) {- this.projectService.allowedToManage(project, uid)- }++ this.projectService.allowedToManage(project, uid, user.roles)+const query1 = `ALTER table analytics DELETE WHERE pid='${id}'`const query2 = `ALTER table customEV DELETE WHERE pid='${id}'`diff --git a/src/project/project.service.ts b/src/project/project.service.tsindex 000bdb83f..66585b05f 100644--- a/src/project/project.service.ts+++ b/src/project/project.service.ts@@ -1,3 +1,4 @@+import { UserType } from './../user/entities/user.entity';import { ForbiddenException, Injectable, BadRequestException, UnprocessableEntityException, InternalServerErrorException } from '@nestjs/common'import { InjectRepository } from '@nestjs/typeorm'import { Repository } from 'typeorm'@@ -11,6 +12,7 @@ import * as _find from 'lodash/find'import * as _map from 'lodash/map'import * as dayjs from 'dayjs'import * as utc from 'dayjs/plugin/utc'+import * as _includes from 'lodash/includes'import { Pagination, PaginationOptionsInterface } from '../common/pagination'import { Project } from './entity/project.entity'@@ -95,8 +97,8 @@ export class ProjectService {}}- allowedToManage(project: Project, uid: string): void {- if (uid === project.admin.id) {+ allowedToManage(project: Project, uid: string, roles: Array<string>): void {+ if (uid === project.admin.id || _includes(roles, UserType.ADMIN)) {return} else {throw new ForbiddenException('You are not allowed to access this project')