Fix redirect when user does not exist

This commit is contained in:
Sofia Baltzi 2017-10-24 11:23:11 +00:00
parent 12816439bd
commit e3395073ab
1 changed files with 5 additions and 4 deletions

View File

@ -56,7 +56,7 @@ public class ForgotPasswordServlet extends HttpServlet {
try { try {
String username = ldapActions.getUsername(formEmail); String username = ldapActions.getUsername(formEmail);
if (username == null) { if (username == null || username.isEmpty()) {
request.getSession().setAttribute("message", "User does not exist."); request.getSession().setAttribute("message", "User does not exist.");
response.sendRedirect("./forgotPassword.jsp"); response.sendRedirect("./forgotPassword.jsp");
@ -84,6 +84,9 @@ public class ForgotPasswordServlet extends HttpServlet {
String verificationCodeSubject = "Your OpenAIRE password reset request"; String verificationCodeSubject = "Your OpenAIRE password reset request";
emailSender.sendEmail(formEmail, verificationCodeSubject, verificationCodeMsg); emailSender.sendEmail(formEmail, verificationCodeSubject, verificationCodeMsg);
response.setContentType("text/html");
response.sendRedirect("./verify.jsp");
} }
} catch (LDAPException ldape) { } catch (LDAPException ldape) {
@ -95,8 +98,6 @@ public class ForgotPasswordServlet extends HttpServlet {
response.sendRedirect("./forgotPassword.jsp"); response.sendRedirect("./forgotPassword.jsp");
} }
response.setContentType("text/html");
response.sendRedirect("./verify.jsp");
} }
} }