Skip to content

Commit

Permalink
Fix Erasmus username generating
Browse files Browse the repository at this point in the history
- Generating accepted null lastName and included it into username.
- Now it does not inlcude it. If the first or last name are null they
  are excluded.
  • Loading branch information
balcirakpeter committed May 10, 2021
1 parent 643319a commit d343997
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,20 @@ private String generateLoginBase(User user) {
ModulesUtilsBlImpl.LoginGenerator generator = new ModulesUtilsBlImpl.LoginGenerator();
return generator.generateLogin(user, (firstName, lastName) -> {

// unable to fill login for users without name or with partial name
if ((firstName == null || firstName.isEmpty()) && (lastName == null || lastName.isEmpty())) {
return "erasmus-user";
//default login
String login = "erasmus-user";

boolean firstNameFilled = firstName != null && !firstName.isEmpty();
boolean lastNameFilled = lastName != null && !lastName.isEmpty();

if (firstNameFilled && lastNameFilled) {
login = firstName+ "-" + lastName;
} else if (firstNameFilled) {
login = firstName;
} else if (lastNameFilled) {
login = lastName;
}

String login = firstName+ "-" + lastName;
if (login.length()>16) {
login = login.substring(0, 16);
}
Expand Down

0 comments on commit d343997

Please sign in to comment.