feat: verify email (CAS-66) #192

Merged
csimonis merged 7 commits from feat/verify-email into main 2025-05-15 09:05:30 +00:00
3 changed files with 4 additions and 4 deletions
Showing only changes of commit decf2e21a3 - Show all commits

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())