use of com.ncedu.fooddelivery.api.v1.dto.jwt.JwtResponseDTO in project 2021-msk-food-delivery by netcracker-edu.
the class AuthServiceImpl method signIn.
@Override
public JwtResponseDTO signIn(JwtRequestDTO authInfo, String userAgent) {
Authentication auth = authenticate(authInfo.getLogin(), authInfo.getPassword());
// User implements UserDetails
User user = (User) auth.getPrincipal();
userService.setLastSigninFromNow(user);
log.debug("USER: " + user.getUsername() + user.getLastSigninDate());
final String accessToken = jwtUtil.createToken(user);
final String refreshToken = userRefreshTokenService.createRefreshToken(user, userAgent);
return new JwtResponseDTO(accessToken, refreshToken, createUserDTO(user));
}
use of com.ncedu.fooddelivery.api.v1.dto.jwt.JwtResponseDTO in project 2021-msk-food-delivery by netcracker-edu.
the class AuthServiceImpl method refresh.
@Override
public JwtResponseDTO refresh(RefreshTokenDTO refreshTokenDTO, String authHeader) {
UUID refreshToken = UUID.fromString(refreshTokenDTO.getRefreshToken());
UserRefreshToken urt = userRefreshTokenService.getTokenById(refreshToken);
// change lastSignin on owner of token
userService.setLastSigninFromNow(urt.getOwner());
final String accessToken = jwtUtil.createToken(urt.getOwner());
return new JwtResponseDTO(accessToken, refreshToken.toString(), createUserDTO(urt.getOwner()));
}
Aggregations