Skip to content

Commit

Permalink
fix: check for existing superuser (#564)
Browse files Browse the repository at this point in the history
  • Loading branch information
maranmaran authored May 3, 2024
1 parent 3243fea commit abf8328
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ public ResponseEntity<Map<String, Object>> createSuperUser(@RequestBody UserInfo
result.put("error", "Please provider password");
return ResponseEntity.ok(result);
}
Optional<UserInfoEntity> optionalUserEntity = usersRepository.findByUserName(userInfoEntity.getName());
if (optionalUserEntity.isPresent()) {
result.put("error", "Superuser already exists");
return ResponseEntity.ok(result);
}

userInfoEntity.setPassword(DigestUtils.sha256Hex(userInfoEntity.getPassword()));
usersRepository.save(userInfoEntity);
Expand Down

0 comments on commit abf8328

Please sign in to comment.