Skip to content

Commit e278182

Browse files
author
eugenp
committed
small fixes
1 parent 12dab9f commit e278182

2 files changed

Lines changed: 10 additions & 20 deletions

File tree

‎spring-security-login-and-registration/src/main/java/org/baeldung/web/controller/RegistrationController.java‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939

4040
@Controller
4141
public class RegistrationController {
42-
4342
private final Logger LOGGER = LoggerFactory.getLogger(getClass());
4443

4544
@Autowired
@@ -111,7 +110,8 @@ public ModelAndView registerUserAccount(@ModelAttribute("user") @Valid final Use
111110
try {
112111
final String appUrl = request.getContextPath();
113112
eventPublisher.publishEvent(new OnRegistrationCompleteEvent(registered, request.getLocale(), appUrl));
114-
} catch (final Exception me) {
113+
} catch (final Exception ex) {
114+
LOGGER.warn("Unable to register user", ex);
115115
return new ModelAndView("emailError", "user", accountDto);
116116
}
117117
return new ModelAndView("successRegister", "user", accountDto);
@@ -126,10 +126,10 @@ public String resendRegistrationToken(final WebRequest request, final Model mode
126126
final SimpleMailMessage email = constructResetVerificationTokenEmail(request.getContextPath(), request.getLocale(), newToken, user);
127127
mailSender.send(email);
128128
} catch (final MailAuthenticationException e) {
129-
LOGGER.debug("MailAuthenticationException");
129+
LOGGER.debug("MailAuthenticationException", e);
130130
return "redirect:/emailError.html?lang=" + locale.getLanguage();
131131
} catch (final Exception e) {
132-
LOGGER.debug(e.getLocalizedMessage());
132+
LOGGER.debug(e.getLocalizedMessage(), e);
133133
model.addAttribute("message", e.getLocalizedMessage());
134134
return "redirect:/login.html?lang=" + locale.getLanguage();
135135
}
@@ -149,13 +149,14 @@ public String resetPassword(final WebRequest request, final Model model, @Reques
149149
userService.createPasswordResetTokenForUser(user, token);
150150
try {
151151
final SimpleMailMessage email = constructResetTokenEmail(request.getContextPath(), request.getLocale(), token, user);
152+
152153
LOGGER.debug(email.getText());
153154
mailSender.send(email);
154155
} catch (final MailAuthenticationException e) {
155-
LOGGER.debug("MailAuthenticationException");
156+
LOGGER.debug("MailAuthenticationException", e);
156157
return "redirect:/emailError.html?lang=" + request.getLocale().getLanguage();
157158
} catch (final Exception e) {
158-
LOGGER.debug(e.getLocalizedMessage());
159+
LOGGER.debug(e.getLocalizedMessage(), e);
159160
model.addAttribute("message", e.getLocalizedMessage());
160161
return "redirect:/login.html?lang=" + request.getLocale().getLanguage();
161162
}
@@ -206,7 +207,6 @@ private final SimpleMailMessage constructResetVerificationTokenEmail(final Strin
206207
final SimpleMailMessage email = new SimpleMailMessage();
207208
email.setSubject("Resend Registration Token");
208209
email.setText(message + " \r\n" + "http://localhost:8080" + confirmationUrl);
209-
210210
email.setTo(user.getEmail());
211211
return email;
212212
}
Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
1-
################### DataSource Configuration ##########################
2-
jdbc.driverClassName=com.mysql.jdbc.Driver
3-
jdbc.url=jdbc:mysql://localhost:3306/registration_02?createDatabaseIfNotExist=true
4-
jdbc.user=tutorialuser
5-
jdbc.pass=tutorialmy5ql
6-
init-db=false
7-
################### Hibernate Configuration ##########################
8-
hibernate.dialect=org.hibernate.dialect.MySQLDialect
9-
hibernate.show_sql=false
10-
hibernate.hbm2ddl.auto=create-drop
111
################### JavaMail Configuration ##########################
12-
smtp.host=smtp.gmail.com
2+
smtp.host=email-smtp.us-east-1.amazonaws.com
133
smtp.port=465
144
smtp.protocol=smtps
15-
smtp.username=xxx777@gmail.com
16-
smtp.password=
5+
smtp.username=AKIAJIKXZAQFFJDXI4VQ
6+
smtp.password=AjYQNjXVTalbpfRL37RYqyXEkyQAvmKFcUFQllfAsBLh
177
support.email=xxx777@gmail.com

0 commit comments

Comments
 (0)