Add username transfer with session - it workssvn st!
This commit is contained in:
parent
223597fa15
commit
b565da194c
|
@ -11,6 +11,7 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
|
@ -38,18 +39,16 @@ public class ResetPasswordServlet extends HttpServlet {
|
|||
response.setContentType("text/html");
|
||||
PrintWriter printWriter = response.getWriter();
|
||||
|
||||
String username = request.getParameter("username");
|
||||
HttpSession session = request.getSession();
|
||||
String username = (String) session.getAttribute("username");
|
||||
|
||||
String password = request.getParameter("password");
|
||||
String confirmPassword = request.getParameter("password_conf");
|
||||
|
||||
//logger.info("username: " + username);
|
||||
logger.info("username: " + username);
|
||||
logger.info("password: " + password);
|
||||
logger.info("confirmPassword: " + confirmPassword);
|
||||
|
||||
//String username = (String)request.getAttribute("username");
|
||||
|
||||
logger.info("username: " + username);
|
||||
|
||||
if (password.equals(confirmPassword) && username != null) {
|
||||
|
||||
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
package eu.dnetlib.openaire.usermanagement;
|
||||
|
||||
import eu.dnetlib.openaire.user.utils.VerificationActions;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
|
@ -26,6 +29,8 @@ public class VerificationCodeServlet extends HttpServlet {
|
|||
@Autowired
|
||||
private VerificationActions verificationActions;
|
||||
|
||||
private Logger logger = Logger.getLogger(VerificationCodeServlet.class);
|
||||
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
response.setContentType("text/html");
|
||||
|
@ -37,6 +42,17 @@ public class VerificationCodeServlet extends HttpServlet {
|
|||
if (verificationActions.verificationEntryExists(formUsername, formVerificationCode)) {
|
||||
//TODO check expiration date if "now" is more than 24h from the date in DB return error message
|
||||
//else go to next step resetPassword.jsp
|
||||
// request.setAttribute("username", formUsername);
|
||||
// RequestDispatcher rd = getServletContext().getRequestDispatcher("/resetPassword.jsp");
|
||||
// try {
|
||||
// rd.forward(request, response);
|
||||
// } catch (ServletException e) {
|
||||
// logger.info("Dispatcher error" + e);
|
||||
// }
|
||||
|
||||
HttpSession session = request.getSession();
|
||||
session.setAttribute("username", formUsername);
|
||||
|
||||
response.sendRedirect("./resetPassword.jsp");
|
||||
printWriter.close();
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||
<%String name=(String)request.getAttribute("name");
|
||||
out.print("your name"+name);%>
|
||||
<html lang="en-gb" dir="ltr" vocab="http://schema.org/">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
|
@ -49,6 +51,7 @@
|
|||
<div id="registerForm">
|
||||
<form action="resetPassword" method="POST" role="form" class="m-t" id="register_form" >
|
||||
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
|
||||
<%--<input type="hidden" name="username" value="${username}"/>--%>
|
||||
<div class="alert alert-success" aria-hidden="true" style="display: none;"></div>
|
||||
<div class="alert alert-danger" aria-hidden="true" style="display: none;"></div>
|
||||
<div class="form-group">
|
||||
|
|
Loading…
Reference in New Issue