Prohibit the registration of unauthorized usernames (#2240)

This commit is contained in:
Ludy 2024-11-15 10:36:59 +01:00 committed by GitHub
parent 4a70d680a4
commit d3ae9f9a81
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -304,7 +304,13 @@ public class UserService implements UserServiceInterface {
boolean isValidEmail =
username.matches(
"^(?=.{1,64}@)[A-Za-z0-9]+(\\.[A-Za-z0-9_+.-]+)*@[^-][A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[A-Za-z]{2,})$");
return isValidSimpleUsername || isValidEmail;
List<String> notAllowedUserList = new ArrayList<>();
notAllowedUserList.add("ALL_USERS".toLowerCase());
boolean notAllowedUser = notAllowedUserList.contains(username.toLowerCase());
return (isValidSimpleUsername || isValidEmail) && !notAllowedUser;
}
private String getInvalidUsernameMessage() {