Merge pull request #1224 from Ludy87/fix_system_exit

Fix: Removes username validation check
This commit is contained in:
Anthony Stirling 2024-05-19 10:25:41 +01:00 committed by GitHub
commit 7c0fd02126
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 5 deletions

View file

@ -54,10 +54,8 @@ public class InitialSecuritySetup {
&& !initialPassword.isEmpty()
&& !userService.findByUsernameIgnoreCase(initialUsername).isPresent()) {
try {
if (userService.isUsernameValid(initialUsername)) {
userService.saveUser(initialUsername, initialPassword, Role.ADMIN.getRoleId());
logger.info("Admin user created: " + initialUsername);
}
userService.saveUser(initialUsername, initialPassword, Role.ADMIN.getRoleId());
logger.info("Admin user created: " + initialUsername);
} catch (IllegalArgumentException e) {
logger.error("Failed to initialize security setup", e);
System.exit(1);

View file

@ -197,7 +197,13 @@ public class UserService implements UserServiceInterface {
}
public boolean hasUsers() {
return userRepository.count() > 0;
long userCount = userRepository.count();
if (userRepository
.findByUsernameIgnoreCase(Role.INTERNAL_API_USER.getRoleId())
.isPresent()) {
userCount -= 1;
}
return userCount > 0;
}
public void updateUserSettings(String username, Map<String, String> updates) {