Method body ready

Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
2020-12-23 14:21:16 +01:00
parent e647698591
commit 507d9fddc0
3 changed files with 43 additions and 4 deletions

View File

@ -25,12 +25,16 @@ public class UserService {
}
public User checkForUser(String email, String usosId) {
return this.checkForUser(email, usosId, UserRoles.STUDENT);
}
public User checkForUser(String email, String usosId, UserRoles roleIfNotExist) {
if (usosId == null) {
Optional<User> user = this.repo.getByAuthority(email.replace("\n", "").trim());
if (user.isPresent()) {
return user.get();
} else {
final User newUser = new User(null, null, email.replace("\n", "").trim(), UserRoles.STUDENT);
final User newUser = new User(null, null, email.replace("\n", "").trim(), roleIfNotExist);
return this.repo.save(newUser);
}
} else {
@ -38,7 +42,7 @@ public class UserService {
if (user.isPresent()) {
return user.get();
} else {
final User newUser = new User(null, null, email.replace("\n", "").trim(), usosId, UserRoles.STUDENT);
final User newUser = new User(null, null, email.replace("\n", "").trim(), usosId, roleIfNotExist);
return this.repo.save(newUser);
}
}