@Override
public Token generateToken(UserDetails userDetails) {
String rawString = userDetails.email + new Date().toString() + userDetails.passwordHash + userDetails.id;
String token = passwordEncoder.encode(rawString);
Date expirationDate = new Date(new Date().getTime() + RestHelper.TOKEN_EXPIRATION_TIME);
RestToken restToken =
new RestToken(userDetails.id, token, expirationDate);
restTokenRepository.save(restToken);
return new Token(restToken.getId(), restToken.getToken(), restToken.getExpirationDate());
}