From e3395073ab779370a510147c3f3a67f81f51eac8 Mon Sep 17 00:00:00 2001 From: Sofia Baltzi <> Date: Tue, 24 Oct 2017 11:23:11 +0000 Subject: [PATCH] Fix redirect when user does not exist --- .../openaire/usermanagement/ForgotPasswordServlet.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/eu/dnetlib/openaire/usermanagement/ForgotPasswordServlet.java b/src/main/java/eu/dnetlib/openaire/usermanagement/ForgotPasswordServlet.java index 2ef9d23..10b3302 100644 --- a/src/main/java/eu/dnetlib/openaire/usermanagement/ForgotPasswordServlet.java +++ b/src/main/java/eu/dnetlib/openaire/usermanagement/ForgotPasswordServlet.java @@ -56,7 +56,7 @@ public class ForgotPasswordServlet extends HttpServlet { try { String username = ldapActions.getUsername(formEmail); - if (username == null) { + if (username == null || username.isEmpty()) { request.getSession().setAttribute("message", "User does not exist."); response.sendRedirect("./forgotPassword.jsp"); @@ -84,6 +84,9 @@ public class ForgotPasswordServlet extends HttpServlet { String verificationCodeSubject = "Your OpenAIRE password reset request"; emailSender.sendEmail(formEmail, verificationCodeSubject, verificationCodeMsg); + + response.setContentType("text/html"); + response.sendRedirect("./verify.jsp"); } } catch (LDAPException ldape) { @@ -94,9 +97,7 @@ public class ForgotPasswordServlet extends HttpServlet { request.getSession().setAttribute("message", "Error sending email."); response.sendRedirect("./forgotPassword.jsp"); } - - response.setContentType("text/html"); - response.sendRedirect("./verify.jsp"); + } }