1
0
mirror of https://github.com/Stirling-Tools/Stirling-PDF.git synced 2024-11-11 02:10:11 +01:00

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() && !initialPassword.isEmpty()
&& !userService.findByUsernameIgnoreCase(initialUsername).isPresent()) { && !userService.findByUsernameIgnoreCase(initialUsername).isPresent()) {
try { try {
if (userService.isUsernameValid(initialUsername)) {
userService.saveUser(initialUsername, initialPassword, Role.ADMIN.getRoleId()); userService.saveUser(initialUsername, initialPassword, Role.ADMIN.getRoleId());
logger.info("Admin user created: " + initialUsername); logger.info("Admin user created: " + initialUsername);
}
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
logger.error("Failed to initialize security setup", e); logger.error("Failed to initialize security setup", e);
System.exit(1); System.exit(1);

View File

@ -197,7 +197,13 @@ public class UserService implements UserServiceInterface {
} }
public boolean hasUsers() { 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) { public void updateUserSettings(String username, Map<String, String> updates) {