Browse Source

fix(server): Prevent delete admin user (#1023)

Alex 2 years ago
parent
commit
614743c8f4
1 changed files with 5 additions and 0 deletions
  1. 5 0
      server/apps/immich/src/api-v1/user/user.service.ts

+ 5 - 0
server/apps/immich/src/api-v1/user/user.service.ts

@@ -119,6 +119,11 @@ export class UserService {
     if (!user) {
     if (!user) {
       throw new BadRequestException('User not found');
       throw new BadRequestException('User not found');
     }
     }
+
+    if (user.isAdmin) {
+      throw new BadRequestException('Cannot delete admin user');
+    }
+
     try {
     try {
       const deletedUser = await this.userRepository.delete(user);
       const deletedUser = await this.userRepository.delete(user);
       return mapUser(deletedUser);
       return mapUser(deletedUser);