Revision 49408
Added by Sofia Baltzi over 6 years ago
modules/dnet-openaire-users/trunk/src/main/java/eu/dnetlib/openaire/usermanagement/VerificationCodeServlet.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.openaire.usermanagement; |
2 | 2 |
|
3 | 3 |
import eu.dnetlib.openaire.user.utils.VerificationActions; |
4 |
import org.apache.log4j.Logger; |
|
4 | 5 |
import org.springframework.beans.factory.annotation.Autowired; |
5 | 6 |
import org.springframework.web.context.support.SpringBeanAutowiringSupport; |
6 | 7 |
|
8 |
import javax.servlet.RequestDispatcher; |
|
7 | 9 |
import javax.servlet.ServletConfig; |
8 | 10 |
import javax.servlet.ServletException; |
9 | 11 |
import javax.servlet.http.HttpServlet; |
10 | 12 |
import javax.servlet.http.HttpServletRequest; |
11 | 13 |
import javax.servlet.http.HttpServletResponse; |
14 |
import javax.servlet.http.HttpSession; |
|
12 | 15 |
import java.io.IOException; |
13 | 16 |
import java.io.PrintWriter; |
14 | 17 |
|
... | ... | |
26 | 29 |
@Autowired |
27 | 30 |
private VerificationActions verificationActions; |
28 | 31 |
|
32 |
private Logger logger = Logger.getLogger(VerificationCodeServlet.class); |
|
33 |
|
|
29 | 34 |
@Override |
30 | 35 |
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { |
31 | 36 |
response.setContentType("text/html"); |
... | ... | |
37 | 42 |
if (verificationActions.verificationEntryExists(formUsername, formVerificationCode)) { |
38 | 43 |
//TODO check expiration date if "now" is more than 24h from the date in DB return error message |
39 | 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 |
HttpSession session = request.getSession(); |
|
54 |
session.setAttribute("username", formUsername); |
|
55 |
|
|
40 | 56 |
response.sendRedirect("./resetPassword.jsp"); |
41 | 57 |
printWriter.close(); |
42 | 58 |
|
modules/dnet-openaire-users/trunk/src/main/java/eu/dnetlib/openaire/usermanagement/ResetPasswordServlet.java | ||
---|---|---|
11 | 11 |
import javax.servlet.http.HttpServlet; |
12 | 12 |
import javax.servlet.http.HttpServletRequest; |
13 | 13 |
import javax.servlet.http.HttpServletResponse; |
14 |
import javax.servlet.http.HttpSession; |
|
14 | 15 |
import java.io.IOException; |
15 | 16 |
import java.io.PrintWriter; |
16 | 17 |
|
... | ... | |
38 | 39 |
response.setContentType("text/html"); |
39 | 40 |
PrintWriter printWriter = response.getWriter(); |
40 | 41 |
|
41 |
String username = request.getParameter("username"); |
|
42 |
HttpSession session = request.getSession(); |
|
43 |
String username = (String) session.getAttribute("username"); |
|
44 |
|
|
42 | 45 |
String password = request.getParameter("password"); |
43 | 46 |
String confirmPassword = request.getParameter("password_conf"); |
44 | 47 |
|
45 |
//logger.info("username: " + username);
|
|
48 |
logger.info("username: " + username); |
|
46 | 49 |
logger.info("password: " + password); |
47 | 50 |
logger.info("confirmPassword: " + confirmPassword); |
48 | 51 |
|
49 |
//String username = (String)request.getAttribute("username"); |
|
50 |
|
|
51 |
logger.info("username: " + username); |
|
52 |
|
|
53 | 52 |
if (password.equals(confirmPassword) && username != null) { |
54 | 53 |
|
55 | 54 |
|
modules/dnet-openaire-users/trunk/src/main/webapp/resetPassword.jsp | ||
---|---|---|
1 | 1 |
<!DOCTYPE html> |
2 | 2 |
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> |
3 |
<%String name=(String)request.getAttribute("name"); |
|
4 |
out.print("your name"+name);%> |
|
3 | 5 |
<html lang="en-gb" dir="ltr" vocab="http://schema.org/"> |
4 | 6 |
<head> |
5 | 7 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
... | ... | |
49 | 51 |
<div id="registerForm"> |
50 | 52 |
<form action="resetPassword" method="POST" role="form" class="m-t" id="register_form" > |
51 | 53 |
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/> |
54 |
<%--<input type="hidden" name="username" value="${username}"/>--%> |
|
52 | 55 |
<div class="alert alert-success" aria-hidden="true" style="display: none;"></div> |
53 | 56 |
<div class="alert alert-danger" aria-hidden="true" style="display: none;"></div> |
54 | 57 |
<div class="form-group"> |
Also available in: Unified diff
Add username transfer with session - it workssvn st!