feat(email): add welcome email sending on verification success
Some checks failed
CI / Get Changed Files (pull_request) Successful in 7s
CI / Docker frontend validation (pull_request) Successful in 12s
CI / eslint (pull_request) Failing after 30s
CI / oxlint (pull_request) Successful in 28s
CI / prettier (pull_request) Failing after 35s
CI / Checkstyle Main (pull_request) Successful in 1m15s
CI / test-build (pull_request) Successful in 50s
CI / Docker backend validation (pull_request) Successful in 1m29s

This commit is contained in:
csimonis 2025-05-15 10:58:53 +02:00
commit decf2e21a3
3 changed files with 4 additions and 4 deletions

View file

@ -36,7 +36,7 @@ public class AuthController {
}
@PostMapping("/verify")
public ResponseEntity<Void> verifyEmail(@RequestParam("token") String token) {
public ResponseEntity<Void> verifyEmail(@RequestParam("token") String token) throws MessagingException, IOException {
if (authService.verifyEmail(token)) {
return ResponseEntity.badRequest().build();
}

View file

@ -63,7 +63,7 @@ public class AuthService {
);
}
public Boolean verifyEmail(String token) {
public Boolean verifyEmail(String token) throws MessagingException, IOException {
Optional<UserEntity> optionalUser = userService.getUserByVerificationToken(token);
if(!optionalUser.isPresent()) {
@ -75,6 +75,7 @@ public class AuthService {
user.setEmailVerified(true);
user.setVerificationToken(null);
userService.saveUser(user);
this.emailService.sendWelcomeEmail(user);
return true;
}

View file

@ -15,7 +15,6 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.util.List;
@Service
public class EmailService {
@ -53,7 +52,7 @@ public class EmailService {
mailSender.send(message);
}
public void sendRegistrationEmail(UserEntity user) throws IOException, MessagingException {
public void sendWelcomeEmail(UserEntity user) throws IOException, MessagingException {
String template = loadTemplate("email/welcome.html");
String htmlContent = template
.replace("${username}", user.getUsername())