Added UserRepositoryTest and users/admin users/deanery

Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
2020-12-27 13:54:33 +01:00
parent da4e683248
commit 817350e85e
6 changed files with 211 additions and 5 deletions

View File

@ -30,7 +30,7 @@ public class UserService {
public User checkForUser(String email, String usosId, UserRoles roleIfNotExist) {
if (usosId == null) {
Optional<User> user = this.repo.getByAuthority(email.replace("\n", "").trim());
Optional<User> user = this.repo.getByEmail(email.replace("\n", "").trim());
if (user.isPresent()) {
return user.get();
} else {
@ -64,11 +64,15 @@ public class UserService {
}
public User getUserByEmail(String email) throws UserNotFoundException {
return this.repo.getByAuthority(email.replace("\n", "").trim())
return this.repo.getByEmail(email.replace("\n", "").trim())
.orElseThrow(() -> new UserNotFoundException("Cannot find user with given authority"));
}
public Optional<User> getByAuthority(String authority) {
return this.repo.getByAuthority(authority);
}
public Optional<User> getByToken(String token) {
return this.repo.getByToken(token);
}