Loading src/users/users.service.ts +17 −1 Original line number Diff line number Diff line Loading @@ -66,7 +66,9 @@ export class UsersService { } async update(id: number, dto: UpdateUserDto, updatedById: number) { if (id == 1) { throw new ConflictException('Cannot update admin user'); } const user = await this.repo.findOne({ where: { id }, relations: ['roles'] }); if (!user) throw new NotFoundException("User not found"); Loading Loading @@ -122,6 +124,10 @@ export class UsersService { } async addRole(userId: number, roleName: string, addedById: number) { if (userId == 1) { throw new ConflictException('Cannot modify admin user'); } const user = await this.repo.findOne({ where: { id: userId }, relations: ['roles'], Loading @@ -144,6 +150,10 @@ export class UsersService { } async removeRole(userId: number, roleName: string, removedById: number) { if (userId == 1) { throw new ConflictException('Cannot modify admin user'); } const user = await this.repo.findOne({ where: { id: userId }, relations: ['roles'], Loading @@ -159,11 +169,17 @@ export class UsersService { } async setEnabled(userId: number, enabled: boolean, updatedById: number) { if (userId == 1) { throw new ConflictException('Cannot modify admin user'); } await this.repo.update(userId, { enabled, updatedById, updatedAt: new Date() }); return this.findOne(userId); } async setForceLogin(userId: number, forceLogin: boolean, updatedById: number) { if (userId == 1) { throw new ConflictException('Cannot modify admin user'); } await this.repo.update(userId, { forceLogin, updatedById, updatedAt: new Date() }); return this.findOne(userId); } Loading Loading
src/users/users.service.ts +17 −1 Original line number Diff line number Diff line Loading @@ -66,7 +66,9 @@ export class UsersService { } async update(id: number, dto: UpdateUserDto, updatedById: number) { if (id == 1) { throw new ConflictException('Cannot update admin user'); } const user = await this.repo.findOne({ where: { id }, relations: ['roles'] }); if (!user) throw new NotFoundException("User not found"); Loading Loading @@ -122,6 +124,10 @@ export class UsersService { } async addRole(userId: number, roleName: string, addedById: number) { if (userId == 1) { throw new ConflictException('Cannot modify admin user'); } const user = await this.repo.findOne({ where: { id: userId }, relations: ['roles'], Loading @@ -144,6 +150,10 @@ export class UsersService { } async removeRole(userId: number, roleName: string, removedById: number) { if (userId == 1) { throw new ConflictException('Cannot modify admin user'); } const user = await this.repo.findOne({ where: { id: userId }, relations: ['roles'], Loading @@ -159,11 +169,17 @@ export class UsersService { } async setEnabled(userId: number, enabled: boolean, updatedById: number) { if (userId == 1) { throw new ConflictException('Cannot modify admin user'); } await this.repo.update(userId, { enabled, updatedById, updatedAt: new Date() }); return this.findOne(userId); } async setForceLogin(userId: number, forceLogin: boolean, updatedById: number) { if (userId == 1) { throw new ConflictException('Cannot modify admin user'); } await this.repo.update(userId, { forceLogin, updatedById, updatedAt: new Date() }); return this.findOne(userId); } Loading