Revision 49412
Added by Sofia Baltzi over 6 years ago
modules/dnet-openaire-users/trunk/src/main/java/eu/dnetlib/openaire/usermanagement/VerificationCodeServlet.java | ||
---|---|---|
41 | 41 |
|
42 | 42 |
if (verificationActions.verificationEntryExists(formUsername, formVerificationCode)) { |
43 | 43 |
//TODO check expiration date if "now" is more than 24h from the date in DB return error message |
44 |
//else go to next step resetPassword.jsp |
|
45 |
// request.setAttribute("username", formUsername); |
|
46 |
// RequestDispatcher rd = getServletContext().getRequestDispatcher("/resetPassword.jsp"); |
|
47 |
// try { |
|
48 |
// rd.forward(request, response); |
|
49 |
// } catch (ServletException e) { |
|
50 |
// logger.info("Dispatcher error" + e); |
|
51 |
// } |
|
52 |
|
|
53 | 44 |
HttpSession session = request.getSession(); |
54 | 45 |
session.setAttribute("username", formUsername); |
55 | 46 |
|
modules/dnet-openaire-users/trunk/src/main/java/eu/dnetlib/openaire/usermanagement/RemindUsernameServlet.java | ||
---|---|---|
8 | 8 |
import org.springframework.stereotype.Component; |
9 | 9 |
import org.springframework.web.context.support.SpringBeanAutowiringSupport; |
10 | 10 |
|
11 |
import javax.mail.MessagingException; |
|
11 | 12 |
import javax.servlet.ServletConfig; |
12 | 13 |
import javax.servlet.ServletException; |
13 | 14 |
import javax.servlet.http.HttpServlet; |
... | ... | |
54 | 55 |
|
55 | 56 |
String verificationCodeSubject = "Your OpenAIRE username"; |
56 | 57 |
|
57 |
emailSender.sendEmail(formEmail, verificationCodeSubject, verificationCodeMsg); |
|
58 | 58 |
|
59 |
emailSender.sendEmail(formEmail, verificationCodeSubject, verificationCodeMsg); |
|
60 |
|
|
61 |
|
|
59 | 62 |
} else { |
60 | 63 |
request.getSession().setAttribute("message", "User not found"); |
61 | 64 |
response.sendRedirect("./remindUsername.jsp"); |
... | ... | |
65 | 68 |
//TODO create error page |
66 | 69 |
logger.error("Could not find user with email " + formEmail, ldape); |
67 | 70 |
response.sendRedirect("./error.jsp"); |
71 |
|
|
72 |
} catch (MessagingException e) { |
|
73 |
logger.error("Error in sending email", e); |
|
74 |
response.sendRedirect("./error.jsp"); |
|
68 | 75 |
} |
76 |
|
|
69 | 77 |
} |
70 | 78 |
|
71 | 79 |
} |
modules/dnet-openaire-users/trunk/src/main/java/eu/dnetlib/openaire/usermanagement/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.mail.MessagingException; |
|
11 | 12 |
import javax.servlet.RequestDispatcher; |
12 | 13 |
import javax.servlet.ServletConfig; |
13 | 14 |
import javax.servlet.ServletException; |
... | ... | |
87 | 88 |
|
88 | 89 |
} catch (LDAPException ldape) { |
89 | 90 |
//TODO create error page |
91 |
logger.error("LDAP error" + ldape); |
|
92 |
response.sendRedirect("./error.jsp"); |
|
93 |
|
|
94 |
} catch (MessagingException e) { |
|
90 | 95 |
request.getSession().setAttribute("message", "Error sending email."); |
91 | 96 |
response.sendRedirect("./forgotPassword.jsp"); |
92 | 97 |
} |
93 | 98 |
|
94 | 99 |
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 |
|
|
117 | 100 |
response.sendRedirect("./verify.jsp"); |
118 | 101 |
} |
119 | 102 |
|
modules/dnet-openaire-users/trunk/src/main/java/eu/dnetlib/openaire/usermanagement/ResetPasswordServlet.java | ||
---|---|---|
45 | 45 |
String password = request.getParameter("password"); |
46 | 46 |
String confirmPassword = request.getParameter("password_conf"); |
47 | 47 |
|
48 |
logger.info("username: " + username); |
|
49 |
logger.info("password: " + password); |
|
50 |
logger.info("confirmPassword: " + confirmPassword); |
|
51 | 48 |
|
52 | 49 |
if (password.equals(confirmPassword) && username != null) { |
53 |
|
|
54 |
|
|
55 |
logger.info("username: " + username); |
|
56 | 50 |
try { |
57 |
|
|
58 | 51 |
ldapActions.resetPassword(username, password); |
59 |
logger.info("password reseted"); |
|
52 |
logger.info("password resetted");
|
|
60 | 53 |
|
61 | 54 |
} catch (Exception e) { |
62 |
e.printStackTrace(); |
|
63 |
request.getSession().setAttribute("message", "Error reseting password."); |
|
64 |
response.sendRedirect("./verify.jsp"); |
|
55 |
logger.error("LDAP error" + e); |
|
56 |
//TODO |
|
57 |
//redirect to helpdesk error page |
|
58 |
//request.getSession().setAttribute("message", "Error resetting password."); |
|
59 |
//response.sendRedirect("./verify.jsp"); |
|
65 | 60 |
} |
66 | 61 |
} |
67 | 62 |
|
modules/dnet-openaire-users/trunk/src/main/webapp/verify.jsp | ||
---|---|---|
53 | 53 |
<div class="alert alert-success" aria-hidden="true" style="display: none;"></div> |
54 | 54 |
<div class="alert alert-danger" aria-hidden="true" style="display: none;"></div> |
55 | 55 |
<div class="form-group"> |
56 |
<span id="server_error" class="uk-text-danger uk-text-small uk-float-left">${message}</span> |
|
56 | 57 |
<span class="msg_username_error uk-text-danger uk-text-small uk-float-left" style="display:none">Please enter your username.</span> |
57 | 58 |
<input id="username" name="username" type="text" placeholder="Username" class="form-control"></div> |
58 | 59 |
<div class="form-group"> |
modules/dnet-openaire-users/trunk/src/main/webapp/resetPassword.jsp | ||
---|---|---|
51 | 51 |
<div id="registerForm"> |
52 | 52 |
<form action="resetPassword" method="POST" role="form" class="m-t" id="register_form" > |
53 | 53 |
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/> |
54 |
<%--<input type="hidden" name="username" value="${username}"/>--%> |
|
55 | 54 |
<div class="alert alert-success" aria-hidden="true" style="display: none;"></div> |
56 | 55 |
<div class="alert alert-danger" aria-hidden="true" style="display: none;"></div> |
57 | 56 |
<div class="form-group"> |
Also available in: Unified diff
Fix exceptions and errors