From e27818266a482b0bc85338e09d23cf09324718b7 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 9 Feb 2015 00:44:52 +0200 Subject: [PATCH] small fixes --- .../web/controller/RegistrationController.java | 14 +++++++------- .../src/main/resources/email.properties | 16 +++------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/spring-security-login-and-registration/src/main/java/org/baeldung/web/controller/RegistrationController.java b/spring-security-login-and-registration/src/main/java/org/baeldung/web/controller/RegistrationController.java index f59604b395..7aaecf1a6d 100644 --- a/spring-security-login-and-registration/src/main/java/org/baeldung/web/controller/RegistrationController.java +++ b/spring-security-login-and-registration/src/main/java/org/baeldung/web/controller/RegistrationController.java @@ -39,7 +39,6 @@ import org.springframework.web.servlet.ModelAndView; @Controller public class RegistrationController { - private final Logger LOGGER = LoggerFactory.getLogger(getClass()); @Autowired @@ -111,7 +110,8 @@ public class RegistrationController { try { final String appUrl = request.getContextPath(); eventPublisher.publishEvent(new OnRegistrationCompleteEvent(registered, request.getLocale(), appUrl)); - } catch (final Exception me) { + } catch (final Exception ex) { + LOGGER.warn("Unable to register user", ex); return new ModelAndView("emailError", "user", accountDto); } return new ModelAndView("successRegister", "user", accountDto); @@ -126,10 +126,10 @@ public class RegistrationController { final SimpleMailMessage email = constructResetVerificationTokenEmail(request.getContextPath(), request.getLocale(), newToken, user); mailSender.send(email); } catch (final MailAuthenticationException e) { - LOGGER.debug("MailAuthenticationException"); + LOGGER.debug("MailAuthenticationException", e); return "redirect:/emailError.html?lang=" + locale.getLanguage(); } catch (final Exception e) { - LOGGER.debug(e.getLocalizedMessage()); + LOGGER.debug(e.getLocalizedMessage(), e); model.addAttribute("message", e.getLocalizedMessage()); return "redirect:/login.html?lang=" + locale.getLanguage(); } @@ -149,13 +149,14 @@ public class RegistrationController { userService.createPasswordResetTokenForUser(user, token); try { final SimpleMailMessage email = constructResetTokenEmail(request.getContextPath(), request.getLocale(), token, user); + LOGGER.debug(email.getText()); mailSender.send(email); } catch (final MailAuthenticationException e) { - LOGGER.debug("MailAuthenticationException"); + LOGGER.debug("MailAuthenticationException", e); return "redirect:/emailError.html?lang=" + request.getLocale().getLanguage(); } catch (final Exception e) { - LOGGER.debug(e.getLocalizedMessage()); + LOGGER.debug(e.getLocalizedMessage(), e); model.addAttribute("message", e.getLocalizedMessage()); return "redirect:/login.html?lang=" + request.getLocale().getLanguage(); } @@ -206,7 +207,6 @@ public class RegistrationController { final SimpleMailMessage email = new SimpleMailMessage(); email.setSubject("Resend Registration Token"); email.setText(message + " \r\n" + "http://localhost:8080" + confirmationUrl); - email.setTo(user.getEmail()); return email; } diff --git a/spring-security-login-and-registration/src/main/resources/email.properties b/spring-security-login-and-registration/src/main/resources/email.properties index b338a128b0..eadc04d8e1 100644 --- a/spring-security-login-and-registration/src/main/resources/email.properties +++ b/spring-security-login-and-registration/src/main/resources/email.properties @@ -1,17 +1,7 @@ -################### DataSource Configuration ########################## -jdbc.driverClassName=com.mysql.jdbc.Driver -jdbc.url=jdbc:mysql://localhost:3306/registration_02?createDatabaseIfNotExist=true -jdbc.user=tutorialuser -jdbc.pass=tutorialmy5ql -init-db=false -################### Hibernate Configuration ########################## -hibernate.dialect=org.hibernate.dialect.MySQLDialect -hibernate.show_sql=false -hibernate.hbm2ddl.auto=create-drop ################### JavaMail Configuration ########################## -smtp.host=smtp.gmail.com +smtp.host=email-smtp.us-east-1.amazonaws.com smtp.port=465 smtp.protocol=smtps -smtp.username=xxx777@gmail.com -smtp.password= +smtp.username=AKIAJIKXZAQFFJDXI4VQ +smtp.password=AjYQNjXVTalbpfRL37RYqyXEkyQAvmKFcUFQllfAsBLh support.email=xxx777@gmail.com