use of com.ncedu.fooddelivery.api.v1.entities.UserRefreshToken in project 2021-msk-food-delivery by netcracker-edu.
the class UserRefreshTokenServiceImpl method createRefreshToken.
@Override
public String createRefreshToken(User owner, String userAgent) {
UserRefreshToken urt = new UserRefreshToken();
Timestamp createDate = Timestamp.valueOf(LocalDateTime.now());
urt.setCreateDate(createDate);
urt.setOwner(owner);
urt.setUserAgent(userAgent);
urt = userRefreshTokenRepo.save(urt);
return urt.getId().toString();
}
use of com.ncedu.fooddelivery.api.v1.entities.UserRefreshToken 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