From 1097d0843f841944e1da64be3f7a54a5fe38837c Mon Sep 17 00:00:00 2001 From: Andrew Lalis Date: Mon, 21 Feb 2022 21:02:14 +0100 Subject: [PATCH] Fixed user stuff again. --- .../coyotecredit/service/UserService.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/nl/andrewl/coyotecredit/service/UserService.java b/src/main/java/nl/andrewl/coyotecredit/service/UserService.java index fc2dd81..5aa481e 100644 --- a/src/main/java/nl/andrewl/coyotecredit/service/UserService.java +++ b/src/main/java/nl/andrewl/coyotecredit/service/UserService.java @@ -89,16 +89,16 @@ public class UserService { user.getAccounts().add(account); user.setActivated(true); user = userRepository.save(user); - } - - String token = StringUtils.random(64); - LocalDateTime expiresAt = LocalDateTime.now(ZoneOffset.UTC).plusHours(24); - UserActivationToken activationToken = new UserActivationToken(token, user, expiresAt); - activationTokenRepository.save(activationToken); - try { - sendActivationEmail(activationToken); - } catch (MessagingException e) { - throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "Could not send activation email."); + } else { + String token = StringUtils.random(64); + LocalDateTime expiresAt = LocalDateTime.now(ZoneOffset.UTC).plusHours(24); + UserActivationToken activationToken = new UserActivationToken(token, user, expiresAt); + activationTokenRepository.save(activationToken); + try { + sendActivationEmail(activationToken); + } catch (MessagingException e) { + throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "Could not send activation email."); + } } }