mav.addObject("error",
"Sorry, we could not find a user with your email address. Please try again.");
mav.addObject("release", env.get("release"));
return mav;
}
SimpleMailMessage message = new SimpleMailMessage();
message.setTo(email);
// Retrieve postmark properties. Keys postmarkApiKey and postmarkSendAddress should be set
// in common.properties
String postmarkSendAddress = env.get("postmarkSendAddress");
String postmarkApiKey = env.get("postmarkApiKey");
// Process postmarkSendAddress
if(postmarkSendAddress==null) {
postmarkSendAddress = "support@fluxtream.com";
logger.warn("component=support_controller action=sendResetRequest" +
" guestId=" + guest.getId() +
" message=\"**** PLEASE SET postmarkSendAddress IN common.properties; defaulting to support@fluxtream.com\"");
}
message.setFrom(postmarkSendAddress);
// Process postmarkApiKey
if(postmarkApiKey==null) {
logger.error("component=support_controller action=sendResetRequest" +
" guestId=" + guest.getId() +
" message=\"**** PLEASE SET postmarkApiKey IN common.properties. Cannot send reset email without it.\"");
ModelAndView mav = new ModelAndView("support/serverConfigError");
mav.addObject("release", env.get("release"));
mav.addObject("userMessage", "We are not able to send email for resetting your password");
mav.addObject("adminMessage", "Please set up the following keys in common.properties to enable email sending: postmarkApiKey and postmarkSendAddress");
return mav;
}
PostmarkMailSender sender = new PostmarkMailSender(
env.get("postmarkApiKey"));
message.setSubject("Fluxtream Reset password request");
Map<String, String> vars = new HashMap<String, String>();
ResetPasswordToken pToken = guestService.createToken(guest.getId());
vars.put("token", pToken.token);
vars.put("homeBaseUrl", env.get("homeBaseUrl"));
if (guest.firstname != null && !guest.firstname.equals(""))
vars.put("username", guest.firstname);
else
vars.put("username", guest.username);
String mailMessage ="Hi " + vars.get("username") + ",\n" +
"\n" +
"Someone requested that your Fluxtream password be reset.\n" +
"\n" +
"If this wasn't you, there's nothing to worry about - simply ignore this email and nothing will change.\n" +
"\n" +
"If you DID ask to reset the password on your Fluxtream account, just click here to make it happen:\n" +
"\n" +
vars.get("homeBaseUrl") + "support/resetPassword?token=" + vars.get("token") + "\n" +
"\n" +
"Thanks,\n" +
"\n" +
"The Fluxtream Team";
message.setText(mailMessage);
sender.send(message);
ModelAndView mav = new ModelAndView("support/resetRequestSent");
mav.addObject("release", env.get("release"));
return mav;
}