Skip to content

Commit

Permalink
Fix error message when deleting user in AdminService
Browse files Browse the repository at this point in the history
  • Loading branch information
Nonononoki committed Jul 17, 2021
1 parent 97b9269 commit a64d732
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/com/nonononoki/alovoa/service/AdminService.java
Expand Up @@ -213,6 +213,10 @@ public void deleteAccount(AdminAccountDeleteDto dto) throws AlovoaException {

User user = userRepo.findByEmail(dto.getEmail());

if (user == null) {
throw new AlovoaException("user_not_found");
}

if (user.isAdmin()) {
throw new AlovoaException("cannot_delete_admin");
}
Expand All @@ -226,8 +230,6 @@ public void deleteAccount(AdminAccountDeleteDto dto) throws AlovoaException {
userRepo.delete(userRepo.findByEmail(user.getEmail()));
userRepo.flush();
}

throw new AlovoaException("user_not_found");
}

private void checkRights() throws AlovoaException {
Expand Down

0 comments on commit a64d732

Please sign in to comment.