use of com.faforever.api.data.domain.Ladder1v1Rating in project faf-java-api by FAForever.
the class UserService method activate.
/**
* Creates a new user based on the information in the activation token.
*
* @param token the JWT in the format: <pre>
* {
* "action": "activate",
* "expiry": "2011-12-03T10:15:30Z",
* "
* }
* </pre>
*/
@SneakyThrows
@SuppressWarnings("unchecked")
@Transactional
void activate(String token, String ipAddress) {
Map<String, String> claims = fafTokenService.resolveToken(FafTokenType.REGISTRATION, token);
String username = claims.get(KEY_USERNAME);
String email = claims.get(KEY_EMAIL);
String password = claims.get(KEY_PASSWORD);
User user = new User();
user.setPassword(password);
user.setEmail(email);
user.setLogin(username);
user.setRecentIpAddress(ipAddress);
user = userRepository.save(user);
// @Deprecated
// TODO: Move this db activity to the server (upcert instead of update) */
// >>>
double mean = properties.getRating().getDefaultMean();
double deviation = properties.getRating().getDefaultDeviation();
globalRatingRepository.save((GlobalRating) new GlobalRating().setId(user.getId()).setMean(mean).setDeviation(deviation));
ladder1v1RatingRepository.save((Ladder1v1Rating) new Ladder1v1Rating().setId(user.getId()).setMean(mean).setDeviation(deviation));
// <<<
log.debug("User has been activated: {}", user);
createOrUpdateMauticContact(user, ipAddress);
}
Aggregations