📈 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
Remove user roles
Blue Mouse33cb09fd1ec0
diff --git a/backend/apps/cloud/src/alert/alert.controller.ts b/backend/apps/cloud/src/alert/alert.controller.tsindex e2294f1ef..a1590d58f 100644--- a/backend/apps/cloud/src/alert/alert.controller.ts+++ b/backend/apps/cloud/src/alert/alert.controller.ts@@ -145,7 +145,6 @@ export class AlertController {this.projectService.allowedToManage(project,uid,- user.roles,'You are not allowed to add alerts to this project',)@@ -240,12 +239,9 @@ export class AlertController {throw new NotFoundException()}- const user = await this.userService.findOne({ where: { id: uid } })-this.projectService.allowedToManage(alert.project,uid,- user.roles,'You are not allowed to manage this alert',)@@ -316,12 +312,9 @@ export class AlertController {throw new NotFoundException()}- const user = await this.userService.findOne({ where: { id: uid } })-this.projectService.allowedToManage(alert.project,uid,- user.roles,'You are not allowed to manage this alert',)diff --git a/backend/apps/cloud/src/marketplace/comments/comments.controller.ts b/backend/apps/cloud/src/marketplace/comments/comments.controller.tsindex b3ad19a5a..778037743 100644--- a/backend/apps/cloud/src/marketplace/comments/comments.controller.ts+++ b/backend/apps/cloud/src/marketplace/comments/comments.controller.ts@@ -17,7 +17,6 @@ import _omit from 'lodash/omit'import { UserService } from '../../user/user.service'import { ExtensionsService } from '../extensions/extensions.service'import { Auth, CurrentUserId } from '../../auth/decorators'-import { UserType } from '../../user/entities/user.entity'import { CommentsService } from './comments.service'import { CreateCommentBodyDto } from './dtos/bodies/create-comment.dto'import { DeleteCommentParamDto } from './dtos/params/delete-comment.dto'@@ -124,9 +123,7 @@ export class CommentsController {throw new NotFoundException('Comment not found.')}- const user = await this.userService.findOne({ where: { id: userId } })-- if (!_includes(user.roles, UserType.ADMIN) && comment.user.id !== userId) {+ if (comment.user.id !== userId) {throw new ConflictException('You are not allowed to do this.')}@@ -222,13 +219,7 @@ export class CommentsController {throw new NotFoundException('Comment reply not found.')}- const user = await this.userService.findOne({ where: { id: userId } })-- if (- !(- commentReply.user.id === userId || _includes(user.roles, UserType.ADMIN)- )- ) {+ if (commentReply.user.id !== userId) {throw new ConflictException('You are not allowed to do this.')}diff --git a/backend/apps/cloud/src/marketplace/extensions/extensions.controller.ts b/backend/apps/cloud/src/marketplace/extensions/extensions.controller.tsindex 1b584975f..ea2ded9e9 100644--- a/backend/apps/cloud/src/marketplace/extensions/extensions.controller.ts+++ b/backend/apps/cloud/src/marketplace/extensions/extensions.controller.ts@@ -444,7 +444,7 @@ export class ExtensionsController {throw new NotFoundException('Project not found.')}- this.projectService.allowedToManage(project, userId, user.roles)+ this.projectService.allowedToManage(project, userId)const extensionToProject =await this.extensionsService.findOneExtensionToProject({@@ -515,7 +515,7 @@ export class ExtensionsController {throw new NotFoundException('Project not found.')}- this.projectService.allowedToManage(project, userId, user.roles)+ this.projectService.allowedToManage(project, userId)const extensionToProject =await this.extensionsService.findOneExtensionToProject({diff --git a/backend/apps/cloud/src/marketplace/extensions/extensions.service.ts b/backend/apps/cloud/src/marketplace/extensions/extensions.service.tsindex 4db8ecf28..668bcca2e 100644--- a/backend/apps/cloud/src/marketplace/extensions/extensions.service.ts+++ b/backend/apps/cloud/src/marketplace/extensions/extensions.service.ts@@ -8,7 +8,7 @@ import { ExtensionToUser } from './entities/extension-to-user.entity'import { Extension } from './entities/extension.entity'import { ICreateExtension } from './interfaces/create-extension.interface'import { ISaveExtension } from './interfaces/save-extension.interface'-import { User, UserType } from '../../user/entities/user.entity'+import { User } from '../../user/entities/user.entity'import { IUpdateExtension } from './interfaces/update-extension.interface'import { CreateExtensionType, UpdateExtensionType } from './types'import { ExtensionStatus } from './enums/extension-status.enum'@@ -210,12 +210,6 @@ export class ExtensionsService {if (!user) return null- if (user.roles.includes(UserType.ADMIN)) {- return this.extensionRepository.findOne({- where: { id: extensionId },- })- }-return this.extensionRepository.findOne({where: { id: extensionId, owner: { id: userId } },})diff --git a/backend/apps/cloud/src/project/project.controller.ts b/backend/apps/cloud/src/project/project.controller.tsindex 19383281f..13799a89d 100644--- a/backend/apps/cloud/src/project/project.controller.ts+++ b/backend/apps/cloud/src/project/project.controller.ts@@ -451,7 +451,7 @@ export class ProjectController {throw new NotFoundException('Project not found.')}- this.projectService.allowedToManage(project, userId, user.roles)+ this.projectService.allowedToManage(project, userId)return this.projectService.createFunnel(project.id, funnelDTO)}@@ -502,7 +502,7 @@ export class ProjectController {throw new NotFoundException('Project not found.')}- this.projectService.allowedToManage(project, userId, user.roles)+ this.projectService.allowedToManage(project, userId)if (_size(project.funnels) >= MAX_FUNNELS) {throw new ForbiddenException(@@ -649,13 +649,12 @@ export class ProjectController {}const project = await this.projectService.getFullProject(pid)- const user = await this.userService.findOne({ where: { id: uid } })if (_isEmpty(project)) {throw new NotFoundException()}- this.projectService.allowedToManage(project, uid, user.roles)+ this.projectService.allowedToManage(project, uid)const secret = generateRandomString(CAPTCHA_SECRET_KEY_LENGTH)@@ -865,7 +864,7 @@ export class ProjectController {)}- this.projectService.allowedToManage(project, userId, user.roles)+ this.projectService.allowedToManage(project, userId)const invitee = await this.userService.findOne({where: { email: shareDTO.email },@@ -960,7 +959,6 @@ export class ProjectController {throw new BadRequestException('The provided ShareUpdateDTO is incorrect')}- const user = await this.userService.findOne({ where: { id: uid } })const share = await this.projectService.findOneShare({where: { id: shareId },relations: [@@ -976,7 +974,7 @@ export class ProjectController {}// TODO: ORG- this.projectService.allowedToManage(share.project, uid, user.roles)+ this.projectService.allowedToManage(share.project, uid)const adminShare = _find(share.project.share,@@ -1162,7 +1160,6 @@ export class ProjectController {this.projectService.allowedToManage(project,userId,- [],"You are not allowed to manage this project's subscribers",)@@ -1206,7 +1203,6 @@ export class ProjectController {this.projectService.allowedToManage(project,userId,- [],"You are not allowed to manage this project's subscribers",)@@ -1354,7 +1350,6 @@ export class ProjectController {this.projectService.allowedToManage(project,userId,- [],"You are not allowed to manage this project's subscribers",)@@ -1592,13 +1587,12 @@ export class ProjectController {this.projectService.validateProject(projectDTO)const project = await this.projectService.getFullProject(id)- const user = await this.userService.findOne({ where: { id: uid } })if (_isEmpty(project)) {throw new NotFoundException()}- this.projectService.allowedToManage(project, uid, user.roles)+ this.projectService.allowedToManage(project, uid)if (_isBoolean(projectDTO.public)) {project.public = projectDTO.public@@ -1677,9 +1671,7 @@ export class ProjectController {throw new NotFoundException(`Project with ID ${pid} does not exist`)}- const user = await this.userService.findOne({ where: { id: uid } })-- this.projectService.allowedToManage(project, uid, user.roles)+ this.projectService.allowedToManage(project, uid)await deleteProjectRedis(pid)await this.projectService.deleteShare(shareId)@@ -1814,13 +1806,13 @@ export class ProjectController {throw new NotFoundException('Project not found.')}- const user = await this.userService.findUserV2(userId, ['roles'])+ const user = await this.userService.findOne({ where: { id: userId } })if (!user) {throw new NotFoundException('User not found.')}- this.projectService.allowedToManage(project, userId, user.roles)+ this.projectService.allowedToManage(project, userId)const createdProjectView =await this.projectsViewsRepository.createProjectView(params.projectId, {@@ -1874,13 +1866,13 @@ export class ProjectController {throw new NotFoundException('Project not found.')}- const user = await this.userService.findUserV2(userId, ['roles'])+ const user = await this.userService.findOne({ where: { id: userId } })if (!user) {throw new NotFoundException('User not found.')}- this.projectService.allowedToManage(project, userId, user.roles)+ this.projectService.allowedToManage(project, userId)const view = await this.projectsViewsRepository.findProjectView(params.projectId,@@ -1920,13 +1912,13 @@ export class ProjectController {throw new NotFoundException('Project not found')}- const user = await this.userService.findUserV2(userId, ['roles'])+ const user = await this.userService.findOne({ where: { id: userId } })if (!user) {throw new NotFoundException('User not found')}- this.projectService.allowedToManage(project, userId, user.roles)+ this.projectService.allowedToManage(project, userId)const view = await this.projectsViewsRepository.findProjectView(params.projectId,diff --git a/backend/apps/cloud/src/project/project.service.ts b/backend/apps/cloud/src/project/project.service.tsindex b1ca88913..a20746b38 100644--- a/backend/apps/cloud/src/project/project.service.ts+++ b/backend/apps/cloud/src/project/project.service.ts@@ -43,7 +43,6 @@ import { Pagination, PaginationOptionsInterface } from '../common/pagination'import { Project } from './entity/project.entity'import { ProjectShare, Role } from './entity/project-share.entity'import { ProjectDTO } from './dto/project.dto'-import { UserType } from '../user/entities/user.entity'import { MAX_PROJECT_PASSWORD_LENGTH } from './dto/project-password.dto'import {isValidPID,@@ -393,7 +392,6 @@ export class ProjectService {},admin: {id: true,- roles: true,dashboardBlockReason: true,isAccountBillingSuspended: true,},@@ -650,12 +648,10 @@ export class ProjectService {allowedToManage(project: Project,uid: string,- roles: Array<UserType> = [],message = 'You are not allowed to manage this project',): void {if (uid === project.admin?.id ||- _includes(roles, UserType.ADMIN) ||_findIndex(project.share,share => share.user?.id === uid && share.role === Role.admin,diff --git a/backend/apps/cloud/src/user/entities/user.entity.ts b/backend/apps/cloud/src/user/entities/user.entity.tsindex d9a48b26b..370298636 100644--- a/backend/apps/cloud/src/user/entities/user.entity.ts+++ b/backend/apps/cloud/src/user/entities/user.entity.ts@@ -183,11 +183,6 @@ export const isNextPlan = (return nextPlanLimit > currentPlanLimit}-export enum UserType {- CUSTOMER = 'customer',- ADMIN = 'admin',-}-export enum ReportFrequency {Never = 'never',Weekly = 'weekly',@@ -234,13 +229,6 @@ export class User {@PrimaryGeneratedColumn('uuid')id: string- @Column({- type: 'set',- enum: UserType,- default: UserType.CUSTOMER,- })- roles: UserType[]-@Column({type: 'set',enum: FeatureFlag,diff --git a/backend/apps/cloud/src/user/user.service.ts b/backend/apps/cloud/src/user/user.service.tsindex 16bbcbaf4..ee367ab93 100644--- a/backend/apps/cloud/src/user/user.service.ts+++ b/backend/apps/cloud/src/user/user.service.ts@@ -606,10 +606,6 @@ export class UserService {return !user}- async findUserV2(id: string, select?: (keyof User)[]) {- return this.usersRepository.findOne({ select, where: { id } })- }-async getReportUsers(reportFrequency:| ReportFrequency.WEEKLYdiff --git a/backend/apps/community/src/user/entities/user.entity.ts b/backend/apps/community/src/user/entities/user.entity.tsindex 3be468868..6e8147c9d 100644--- a/backend/apps/community/src/user/entities/user.entity.ts+++ b/backend/apps/community/src/user/entities/user.entity.ts@@ -1,10 +1,5 @@import _omit from 'lodash/omit'-export enum UserType {- CUSTOMER = 'customer',- ADMIN = 'admin',-}-export enum TimeFormat {'12-hour' = '12-hour','24-hour' = '24-hour',diff --git a/backend/migrations/mysql/2025_10_12.sql b/backend/migrations/mysql/2025_10_12.sqlnew file mode 100644index 000000000..ade72515e--- /dev/null+++ b/backend/migrations/mysql/2025_10_12.sql@@ -0,0 +1 @@+alter table user drop column roles;