Skip to content

High performance self-hosted photo and video management solution.

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

Alex614743c8f42f
diff --git a/server/apps/immich/src/api-v1/user/user.service.ts b/server/apps/immich/src/api-v1/user/user.service.ts
index 311561856f..6fe2aafefd 100644
--- a/server/apps/immich/src/api-v1/user/user.service.ts
+++ b/server/apps/immich/src/api-v1/user/user.service.ts
@@ -119,6 +119,11 @@ export class UserService {
if (!user) {
throw new BadRequestException('User not found');
}
+
+ if (user.isAdmin) {
+ throw new BadRequestException('Cannot delete admin user');
+ }
+
try {
const deletedUser = await this.userRepository.delete(user);
return mapUser(deletedUser);