Revision 49406
Added by Sofia Baltzi over 6 years ago
ForgotPasswordServlet.java | ||
---|---|---|
8 | 8 |
import org.springframework.beans.factory.annotation.Autowired; |
9 | 9 |
import org.springframework.web.context.support.SpringBeanAutowiringSupport; |
10 | 10 |
|
11 |
import javax.servlet.RequestDispatcher; |
|
11 | 12 |
import javax.servlet.ServletConfig; |
12 | 13 |
import javax.servlet.ServletException; |
13 | 14 |
import javax.servlet.http.HttpServlet; |
... | ... | |
46 | 47 |
|
47 | 48 |
String formEmail = request.getParameter("email"); |
48 | 49 |
|
49 |
logger.debug("I am in do post for " + formEmail); |
|
50 |
|
|
51 | 50 |
if (formEmail == null) { |
52 | 51 |
request.getSession().setAttribute("message", "Error reading email."); |
53 | 52 |
response.sendRedirect("./forgotPassword.jsp"); |
... | ... | |
56 | 55 |
try { |
57 | 56 |
|
58 | 57 |
String username = ldapActions.getUsername(formEmail); |
59 |
|
|
60 | 58 |
if (username == null) { |
61 | 59 |
request.getSession().setAttribute("message", "User does not exist."); |
62 | 60 |
response.sendRedirect("./forgotPassword.jsp"); |
... | ... | |
67 | 65 |
|
68 | 66 |
Timestamp timestamp = new Timestamp(creationDate.getTime()); |
69 | 67 |
|
70 |
//logger.info("verificationCode = " + verificationCode); |
|
71 |
|
|
72 | 68 |
if (!verificationActions.verificationEntryExists(username)) { |
73 | 69 |
verificationActions.addVerificationEntry(username, verificationCode.toString(), timestamp); |
74 | 70 |
|
... | ... | |
82 | 78 |
"password, you will need to submit this verification code in order to verify that the\n" + |
83 | 79 |
"request was legitimate.\n" + |
84 | 80 |
"\n" + |
85 |
"The verification code is" + verificationCode.toString() + "\n Thank you"; |
|
81 |
"The verification code is " + verificationCode.toString() + "\n Thank you";
|
|
86 | 82 |
|
87 | 83 |
String verificationCodeSubject = "Your OpenAIRE password reset request"; |
88 | 84 |
|
89 | 85 |
emailSender.sendEmail(formEmail, verificationCodeSubject, verificationCodeMsg); |
90 |
|
|
91 | 86 |
} |
92 | 87 |
|
93 |
|
|
94 | 88 |
} catch (LDAPException ldape) { |
95 | 89 |
//TODO create error page |
96 | 90 |
request.getSession().setAttribute("message", "Error sending email."); |
... | ... | |
98 | 92 |
} |
99 | 93 |
|
100 | 94 |
response.setContentType("text/html"); |
95 |
// try { |
|
96 |
//// request.getSession().setAttribute("email", formEmail); |
|
97 |
//// request.getSession().setAttribute("username", ldapActions.getUsername(formEmail)); |
|
98 |
//// request.setAttribute("email", formEmail); |
|
99 |
// request.setAttribute("username", ldapActions.getUsername(formEmail)); |
|
100 |
// RequestDispatcher rd = request.getRequestDispatcher("./verify.jsp"); |
|
101 |
// rd.forward(request, response); |
|
102 |
//// RequestDispatcher rd = request.getRequestDispatcher("ForgotPasswordServlet"); |
|
103 |
//// rd.forward(request, response); |
|
104 |
//// |
|
105 |
//// logger.info("Stelnwwww"); |
|
106 |
//// |
|
107 |
// } catch (LDAPException e) { |
|
108 |
// e.printStackTrace(); |
|
109 |
// logger.info("LDAP error" + e); |
|
110 |
// request.getSession().setAttribute("message", "Error getting username."); |
|
111 |
// response.sendRedirect("./forgotPassword.jsp"); |
|
112 |
// } catch (ServletException ex) { |
|
113 |
// ex.printStackTrace(); |
|
114 |
// logger.info("Dispacher error" + ex); |
|
115 |
// } |
|
116 |
|
|
101 | 117 |
response.sendRedirect("./verify.jsp"); |
102 | 118 |
} |
103 | 119 |
|
Also available in: Unified diff
Fic errors! It works!