diff --git a/src/main/java/org/apache/pulsar/manager/controller/UsersController.java b/src/main/java/org/apache/pulsar/manager/controller/UsersController.java index b4996cab..21f2f24d 100644 --- a/src/main/java/org/apache/pulsar/manager/controller/UsersController.java +++ b/src/main/java/org/apache/pulsar/manager/controller/UsersController.java @@ -218,6 +218,11 @@ public ResponseEntity> createSuperUser(@RequestBody UserInfo result.put("error", "Please provider password"); return ResponseEntity.ok(result); } + Optional 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);