Redirect to forgotPassword if the username in the session is null

This commit is contained in:
Sofia Baltzi 2017-10-19 11:38:08 +00:00
parent 34426bebfd
commit 0aacea1686
2 changed files with 17 additions and 23 deletions

View File

@ -45,26 +45,20 @@ public class ResetPasswordServlet extends HttpServlet {
String password = request.getParameter("password");
String confirmPassword = request.getParameter("password_conf");
// if (username != null) {
if (password.equals(confirmPassword) && username != null) {
try {
ldapActions.resetPassword(username, password);
logger.info("password resetted");
if (password.equals(confirmPassword) && username != null) {
try {
ldapActions.resetPassword(username, password);
logger.info("password resetted");
} catch (Exception e) {
logger.error("LDAP error in resetting password", e);
response.sendRedirect("./error.jsp");
}
} catch (Exception e) {
logger.error("LDAP error in resetting password", e);
response.sendRedirect("./error.jsp");
}
}
session.removeAttribute("username");
response.sendRedirect("./success.jsp");
printWriter.close();
session.removeAttribute("username");
response.sendRedirect("./success.jsp");
printWriter.close();
// } else {
// response.sendRedirect("./forgotPassword.jsp");
// printWriter.close();
// }
}
}

View File

@ -1,10 +1,10 @@
<!DOCTYPE html>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%--<% if (session.getAttribute("username") == null) {--%>
<%--String redirectURL = "/dnet-openaire-users-1.0.0-SNAPSHOT/forgotPassword.jsp";--%>
<%--response.sendRedirect(redirectURL);--%>
<%--}--%>
<%--%>--%>
<% if (session.getAttribute("username") == null) {
String redirectURL = "/dnet-openaire-users-1.0.0-SNAPSHOT/forgotPassword.jsp";
response.sendRedirect(redirectURL);
}
%>
<%--<%String name=(String)request.getAttribute("name");--%>
<%--out.print("your name"+name);%>--%>
<html lang="en-gb" dir="ltr" vocab="http://schema.org/">
@ -85,7 +85,7 @@
// When the user starts to type something inside the password field
myInput.onkeyup = function() {
// Validate lowercase letters
var lowerCaseLetters = /[a-z]/g;
if (myInput.value.match(lowerCaseLetters)) {