Ejemplo n.º 1
0
 @Transactional
 @Override
 public String findToken(UserAuth userAuth) throws UserNotFoundException {
   Authentication userAuthentication =
       authenticationRepository.findByIdUser(userService.findByUserAuth(userAuth));
   if (userAuthentication == null) throw new UserNotFoundException();
   return userAuthentication.getToken();
 }
Ejemplo n.º 2
0
  @Override
  public Long findToken(String token) throws UserNotFoundException {
    Authentication authentication = authenticationRepository.findByToken(token);

    if (authentication == null) throw new UserNotFoundException();

    return authentication.getIdUser();
  }
Ejemplo n.º 3
0
 @Transactional
 @Override
 public Authentication create(UserAuth userAuth) throws UserNotFoundException {
   Authentication userAuthentication = new Authentication();
   userAuthentication.setIdUser(userService.findByUserAuth(userAuth));
   userAuthentication.setToken(new Integer(userAuth.getUsername().hashCode()).toString());
   authenticationRepository.save(userAuthentication);
   return userAuthentication;
 }