CAS Part 2

Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
2020-12-03 16:57:53 +01:00
parent 3ebfda5316
commit 453907782a
7 changed files with 51 additions and 53 deletions

View File

@ -32,8 +32,7 @@ public class UserService {
}
else {
final User newUser = new User(null,null,email.replace("\n", "").trim(),UserRoles.STUDENT);
this.repo.save(newUser);
return newUser;
return this.repo.save(newUser);
}
}
else {
@ -43,19 +42,20 @@ public class UserService {
}
else {
final User newUser = new User(null,null,email.replace("\n", "").trim(),usosId,UserRoles.STUDENT);
this.repo.save(newUser);
return newUser;
return this.repo.save(newUser);
}
}
}
public String login(String authority) throws UserNotFoundException {
User user = this.repo.getByAuthority(authority.replace("\n", "").trim())
.orElseThrow(() -> new UserNotFoundException("Can not find user with given authority"));
public String login(User authority) throws UserNotFoundException {
final String token = UUID.randomUUID().toString();
user.setToken(token);
this.repo.save(user);
try{
authority.setToken(token);
this.repo.save(authority);
}
catch (Exception e){
throw new UserNotFoundException(e.getMessage());
}
return token;
}