Fix: Removes username validation check

- Removes username validation check
- Ignores API users in user counting
This commit is contained in:
Ludy87 2024-05-19 10:52:11 +02:00
parent e30665e7c8
commit 7109dd7905
No known key found for this signature in database
GPG key ID: 92696155E0220F94
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) {