Merge branch 'main' into session_2025_03_22

This commit is contained in:
Ludy 2025-03-30 18:19:18 +02:00 committed by GitHub
commit f33d8b0f23
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 50 additions and 32 deletions

View File

@ -139,7 +139,7 @@ Stirling-PDF currently supports 39 languages!
| Korean (한국어) (ko_KR) | ![95%](https://geps.dev/progress/95) | | Korean (한국어) (ko_KR) | ![95%](https://geps.dev/progress/95) |
| Norwegian (Norsk) (no_NB) | ![89%](https://geps.dev/progress/89) | | Norwegian (Norsk) (no_NB) | ![89%](https://geps.dev/progress/89) |
| Persian (فارسی) (fa_IR) | ![90%](https://geps.dev/progress/90) | | Persian (فارسی) (fa_IR) | ![90%](https://geps.dev/progress/90) |
| Polish (Polski) (pl_PL) | ![82%](https://geps.dev/progress/82) | | Polish (Polski) (pl_PL) | ![98%](https://geps.dev/progress/98) |
| Portuguese (Português) (pt_PT) | ![93%](https://geps.dev/progress/93) | | Portuguese (Português) (pt_PT) | ![93%](https://geps.dev/progress/93) |
| Portuguese Brazilian (Português) (pt_BR) | ![96%](https://geps.dev/progress/96) | | Portuguese Brazilian (Português) (pt_BR) | ![96%](https://geps.dev/progress/96) |
| Romanian (Română) (ro_RO) | ![77%](https://geps.dev/progress/77) | | Romanian (Română) (ro_RO) | ![77%](https://geps.dev/progress/77) |

View File

@ -204,6 +204,7 @@ public class UserService implements UserServiceInterface {
user.setPassword(passwordEncoder.encode(password)); user.setPassword(passwordEncoder.encode(password));
user.setEnabled(true); user.setEnabled(true);
user.setAuthenticationType(AuthenticationType.WEB); user.setAuthenticationType(AuthenticationType.WEB);
user.addAuthority(new Authority(Role.USER.getRoleId(), user));
userRepository.save(user); userRepository.save(user);
databaseService.exportDatabase(); databaseService.exportDatabase();
} }
@ -229,6 +230,22 @@ public class UserService implements UserServiceInterface {
saveUser(username, password, role, false); saveUser(username, password, role, false);
} }
public void saveUser(String username, String password, boolean firstLogin, boolean enabled)
throws IllegalArgumentException, SQLException, UnsupportedProviderException {
if (!isUsernameValid(username)) {
throw new IllegalArgumentException(getInvalidUsernameMessage());
}
User user = new User();
user.setUsername(username);
user.setPassword(passwordEncoder.encode(password));
user.addAuthority(new Authority(Role.USER.getRoleId(), user));
user.setEnabled(enabled);
user.setAuthenticationType(AuthenticationType.WEB);
user.setFirstLogin(firstLogin);
userRepository.save(user);
databaseService.exportDatabase();
}
public void deleteUser(String username) { public void deleteUser(String username) {
Optional<User> userOpt = findByUsernameIgnoreCase(username); Optional<User> userOpt = findByUsernameIgnoreCase(username);
if (userOpt.isPresent()) { if (userOpt.isPresent()) {
@ -351,6 +368,7 @@ public class UserService implements UserServiceInterface {
List<String> notAllowedUserList = new ArrayList<>(); List<String> notAllowedUserList = new ArrayList<>();
notAllowedUserList.add("ALL_USERS".toLowerCase()); notAllowedUserList.add("ALL_USERS".toLowerCase());
notAllowedUserList.add("anonymoususer");
boolean notAllowedUser = notAllowedUserList.contains(username.toLowerCase()); boolean notAllowedUser = notAllowedUserList.contains(username.toLowerCase());
return (isValidSimpleUsername || isValidEmail) && !notAllowedUser; return (isValidSimpleUsername || isValidEmail) && !notAllowedUser;
} }