Add variables in session
This commit is contained in:
parent
387f7ca4bf
commit
36c29f3c5e
|
@ -62,18 +62,6 @@ public class RegisterServlet extends HttpServlet {
|
|||
|
||||
try {
|
||||
|
||||
// if (ldapActions.usernameExists(username)) {
|
||||
// request.getSession().setAttribute("username_message", "Username already exists! Choose another one.");
|
||||
// logger.info("Username already exists");
|
||||
// response.sendRedirect("./register.jsp");
|
||||
//
|
||||
// } else if (ldapActions.emailExists(email)) {
|
||||
// request.getSession().setAttribute("email_message", "There is another user with this email.");
|
||||
// logger.info("There is another user with this email");
|
||||
// response.sendRedirect("./register.jsp");
|
||||
//
|
||||
// } else {
|
||||
|
||||
if (username.matches("^[a-zA-Z0-9][a-zA-Z0-9_-]{4,150}") && !ldapActions.usernameExists(username) && !ldapActions.emailExists(email)) {
|
||||
|
||||
ldapActions.createUser(username, email, firstName, lastName, organization/*, password*/);
|
||||
|
@ -103,9 +91,8 @@ public class RegisterServlet extends HttpServlet {
|
|||
|
||||
emailSender.sendEmail(email, verificationCodeSubject, verificationCodeMsg);
|
||||
|
||||
|
||||
response.sendRedirect("./activate.jsp");
|
||||
// }
|
||||
|
||||
} else {
|
||||
|
||||
if(!username.matches("^[a-zA-Z0-9][a-zA-Z0-9_-]{4,150}")){
|
||||
|
@ -131,6 +118,13 @@ public class RegisterServlet extends HttpServlet {
|
|||
logger.info("There is another user with this email");
|
||||
}
|
||||
|
||||
request.getSession().setAttribute("first_name", firstName);
|
||||
request.getSession().setAttribute("last_name", lastName);
|
||||
request.getSession().setAttribute("organization", organization);
|
||||
request.getSession().setAttribute("username", username);
|
||||
request.getSession().setAttribute("email", email);
|
||||
request.getSession().setAttribute("email_conf", confirmEmail);
|
||||
|
||||
response.sendRedirect("./register.jsp");
|
||||
}
|
||||
|
||||
|
|
|
@ -63,28 +63,34 @@
|
|||
<div class="alert alert-danger" aria-hidden="true" style="display: none;"></div>
|
||||
<div class="form-group">
|
||||
<span class="msg_first_name_error uk-text-danger uk-text-small uk-float-left" style="display:none">Please enter your first name.</span>
|
||||
<input id="first_name" name="first_name" type="text" placeholder="First name (*)" class="form-control"></div>
|
||||
<input id="first_name" name="first_name" type="text" placeholder="First name (*)" class="form-control" value=${first_name}></div>
|
||||
<c:remove var="first_name" scope="session" />
|
||||
<div class="form-group">
|
||||
<span class="msg_last_name_error uk-text-danger uk-text-small uk-float-left" style="display:none">Please enter your last name.</span>
|
||||
<input id="last_name" name="last_name" type="text" placeholder="Last name (*)" class="form-control"></div>
|
||||
<input id="last_name" name="last_name" type="text" placeholder="Last name (*)" class="form-control" value=${last_name}></div>
|
||||
<c:remove var="last_name" scope="session" />
|
||||
<div class="form-group">
|
||||
<input id="organization" name="organization" type="text" placeholder="Affiliation / Organization:" class="form-control"></div>
|
||||
<input id="organization" name="organization" type="text" placeholder="Affiliation / Organization:" class="form-control" value=${organization}></div>
|
||||
<c:remove var="organization" scope="session" />
|
||||
<div class="form-group">
|
||||
<span class="msg_username_min_lenght uk-text-danger uk-text-small uk-float-left" style="display:none">Minimum username length 5 characters.</span>
|
||||
<span class="msg_username_max_lenght uk-text-danger uk-text-small uk-float-left" style="display:none">Maximum username lenght 150 characters.</span>
|
||||
<span class="msg_username_error uk-text-danger uk-text-small uk-float-left" style="display:none">Please enter your username.</span>
|
||||
<span id="username_server_error" class="uk-text-danger uk-text-small uk-float-left">${username_message}</span>
|
||||
<c:remove var="username_message" scope="session" />
|
||||
<input id="username" name="username" type="text" placeholder="Username (*)" class="form-control"></div>
|
||||
<input id="username" name="username" type="text" placeholder="Username (*)" class="form-control" value=${username}></div>
|
||||
<c:remove var="username" scope="session" />
|
||||
<div class="form-group">
|
||||
<span class="msg_email_error uk-text-danger uk-text-small uk-float-left" style="display:none">Please enter your email.</span>
|
||||
<span class="msg_email_validation_error uk-text-danger uk-text-small uk-float-left" style="display:none">Please enter a valid email.</span>
|
||||
<span class="msg_email_conf_error uk-text-danger uk-text-small uk-float-left" style="display:none">These emails don't match.</span>
|
||||
<span id="email_server_error" class="uk-text-danger uk-text-small uk-float-left">${email_message}</span>
|
||||
<c:remove var="email_message" scope="session" />
|
||||
<input id="email" name="email" type="text" placeholder="Email (*)" class="form-control"></div>
|
||||
<input id="email" name="email" type="text" placeholder="Email (*)" class="form-control" value=${email}></div>
|
||||
<c:remove var="email" scope="session" />
|
||||
<div class="form-group">
|
||||
<input id="email_conf" name="email_conf" type="text" placeholder="Confirm email (*)" class="form-control"></div>
|
||||
<input id="email_conf" name="email_conf" type="text" placeholder="Confirm email (*)" class="form-control" value=${email_conf}></div>
|
||||
<c:remove var="email_conf" scope="session" />
|
||||
<%--<div class="form-group">--%>
|
||||
<%--<span class="msg_password_error uk-text-danger uk-text-small uk-float-left" style="display:none">Please enter your password.</span>--%>
|
||||
<%--<span class="msg_pass_conf_error uk-text-danger uk-text-small uk-float-left" style="display:none">These passwords don't match.</span>--%>
|
||||
|
@ -222,46 +228,46 @@
|
|||
});
|
||||
|
||||
|
||||
// Run on page load
|
||||
window.onload = function() {
|
||||
|
||||
// // If sessionStorage is storing default values (ex. name), exit the function and do not restore data
|
||||
// if (sessionStorage.getItem('name') == "name") {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// If values are not blank, restore them to the fields
|
||||
|
||||
var first_name = sessionStorage.getItem('first_name');
|
||||
if (first_name !== null) $('#first_name').val(first_name);
|
||||
|
||||
var last_name = sessionStorage.getItem('last_name');
|
||||
if (last_name !== null) $('#last_name').val(last_name);
|
||||
|
||||
var organization = sessionStorage.getItem('organization');
|
||||
if (organization !== null) $('#organization').val(organization);
|
||||
|
||||
var username = sessionStorage.getItem('username');
|
||||
if (username !== null) $('#username').val(username);
|
||||
|
||||
var email = sessionStorage.getItem('email');
|
||||
if (email !== null) $('#email').val(email);
|
||||
|
||||
var email_conf= sessionStorage.getItem('email_conf');
|
||||
if (email_conf!== null) $('#email_conf').val(email_conf);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Before refreshing the page, save the form data to sessionStorage
|
||||
window.onbeforeunload = function() {
|
||||
sessionStorage.setItem("first_name", $('#first_name').val());
|
||||
sessionStorage.setItem("last_name", $('#last_name').val());
|
||||
sessionStorage.setItem("organization", $('#organization').val());
|
||||
sessionStorage.setItem("username", $('#username').val());
|
||||
sessionStorage.setItem("email", $('#email').val());
|
||||
sessionStorage.setItem("email_conf", $('#email_conf').val());
|
||||
}
|
||||
// // Run on page load
|
||||
// window.onload = function() {
|
||||
//
|
||||
//// // If sessionStorage is storing default values (ex. name), exit the function and do not restore data
|
||||
//// if (sessionStorage.getItem('name') == "name") {
|
||||
//// return;
|
||||
//// }
|
||||
//
|
||||
// // If values are not blank, restore them to the fields
|
||||
//
|
||||
// var first_name = sessionStorage.getItem('first_name');
|
||||
// if (first_name !== null) $('#first_name').val(first_name);
|
||||
//
|
||||
// var last_name = sessionStorage.getItem('last_name');
|
||||
// if (last_name !== null) $('#last_name').val(last_name);
|
||||
//
|
||||
// var organization = sessionStorage.getItem('organization');
|
||||
// if (organization !== null) $('#organization').val(organization);
|
||||
//
|
||||
// var username = sessionStorage.getItem('username');
|
||||
// if (username !== null) $('#username').val(username);
|
||||
//
|
||||
// var email = sessionStorage.getItem('email');
|
||||
// if (email !== null) $('#email').val(email);
|
||||
//
|
||||
// var email_conf= sessionStorage.getItem('email_conf');
|
||||
// if (email_conf!== null) $('#email_conf').val(email_conf);
|
||||
//
|
||||
//
|
||||
// }
|
||||
//
|
||||
// // Before refreshing the page, save the form data to sessionStorage
|
||||
// window.onbeforeunload = function() {
|
||||
// sessionStorage.setItem("first_name", $('#first_name').val());
|
||||
// sessionStorage.setItem("last_name", $('#last_name').val());
|
||||
// sessionStorage.setItem("organization", $('#organization').val());
|
||||
// sessionStorage.setItem("username", $('#username').val());
|
||||
// sessionStorage.setItem("email", $('#email').val());
|
||||
// sessionStorage.setItem("email_conf", $('#email_conf').val());
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue