Trim input fields at the backend

This commit is contained in:
Sofia Baltzi 2017-11-07 10:56:43 +00:00
parent d58ca25c5e
commit 77191f58c4
7 changed files with 15 additions and 15 deletions

View File

@ -40,8 +40,8 @@ public class ActivationCodeServlet extends HttpServlet{
response.setContentType("text/html"); response.setContentType("text/html");
PrintWriter printWriter = response.getWriter(); PrintWriter printWriter = response.getWriter();
String formUsername = request.getParameter("username"); String formUsername = request.getParameter("username").trim();
String formVerificationCode = request.getParameter("verification_code"); String formVerificationCode = request.getParameter("verification_code").trim();
if (verificationActions.verificationEntryExists(formUsername) && verificationActions.verificationCodeIsCorrect(formUsername, formVerificationCode)) { if (verificationActions.verificationEntryExists(formUsername) && verificationActions.verificationCodeIsCorrect(formUsername, formVerificationCode)) {
if (!verificationActions.verificationCodeHasExpired(formUsername)) { if (!verificationActions.verificationCodeHasExpired(formUsername)) {

View File

@ -46,7 +46,7 @@ public class ForgotPasswordServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
String formEmail = request.getParameter("email"); String formEmail = request.getParameter("email").trim();
if (formEmail == null) { if (formEmail == null) {
request.getSession().setAttribute("message", "Error reading email."); request.getSession().setAttribute("message", "Error reading email.");

View File

@ -45,12 +45,12 @@ public class RegisterServlet extends HttpServlet {
response.setContentType("text/html"); response.setContentType("text/html");
PrintWriter printWriter = response.getWriter(); PrintWriter printWriter = response.getWriter();
String firstName = request.getParameter("first_name"); String firstName = request.getParameter("first_name").trim();
String lastName = request.getParameter("last_name"); String lastName = request.getParameter("last_name").trim();
String organization = request.getParameter("organization"); String organization = request.getParameter("organization").trim();
String username = request.getParameter("username"); String username = request.getParameter("username").trim();
String email =request.getParameter("email"); String email =request.getParameter("email").trim();
String confirmEmail = request.getParameter("email_conf"); String confirmEmail = request.getParameter("email_conf").trim();
String password = request.getParameter("password"); String password = request.getParameter("password");
String confirmPassword = request.getParameter("password_conf"); String confirmPassword = request.getParameter("password_conf");
@ -65,7 +65,7 @@ public class RegisterServlet extends HttpServlet {
if (username.matches("^[a-zA-Z0-9][a-zA-Z0-9_-]{4,150}") && !ldapActions.usernameExists(username) && !ldapActions.emailExists(email)) { if (username.matches("^[a-zA-Z0-9][a-zA-Z0-9_-]{4,150}") && !ldapActions.usernameExists(username) && !ldapActions.emailExists(email)) {
ldapActions.createZombieUser(username, email, firstName, lastName, organization, password); ldapActions.createZombieUser(username, email, firstName, lastName, organization, password);
logger.info("User successfully created"); logger.info("Zombie user successfully created");
UUID verificationCode = UUID.randomUUID(); UUID verificationCode = UUID.randomUUID();
Date creationDate = new Date(); Date creationDate = new Date();

View File

@ -38,7 +38,7 @@ public class RemindUsernameServlet extends HttpServlet {
@Override @Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
String formEmail = request.getParameter("email"); String formEmail = request.getParameter("email").trim();
if (formEmail == null){ if (formEmail == null){
request.getSession().setAttribute("message", "Error reading email."); request.getSession().setAttribute("message", "Error reading email.");

View File

@ -36,8 +36,8 @@ public class VerificationCodeServlet extends HttpServlet {
response.setContentType("text/html"); response.setContentType("text/html");
PrintWriter printWriter = response.getWriter(); PrintWriter printWriter = response.getWriter();
String formUsername = request.getParameter("username"); String formUsername = request.getParameter("username").trim();
String formVerificationCode = request.getParameter("verification_code"); String formVerificationCode = request.getParameter("verification_code").trim();
if (verificationActions.verificationEntryExists(formUsername) && verificationActions.verificationCodeIsCorrect(formUsername, formVerificationCode)) { if (verificationActions.verificationEntryExists(formUsername) && verificationActions.verificationCodeIsCorrect(formUsername, formVerificationCode)) {
if (!verificationActions.verificationCodeHasExpired(formUsername)) { if (!verificationActions.verificationCodeHasExpired(formUsername)) {

View File

@ -51,7 +51,7 @@
<!-- CENTER SIDE --> <!-- CENTER SIDE -->
<div class="uk-width-1-1@m uk-width-1-1@s uk-text-center"> <div class="uk-width-1-1@m uk-width-1-1@s uk-text-center">
<div class="middle-box text-center loginscreen animated fadeInDown "> <div class="middle-box text-center loginscreen animated fadeInDown ">
<p>An email has been sent to your email address. The email contains your username and an activation code, please paste them in the fields below to prove that you are the owner of this email account.</p> <p>Thank you for registering! Please activate your account. An email has been sent to your email address. The email contains your username and an activation code, please paste them in the fields below to prove that you are the owner of this email account.</p>
<div class="uk-width-1-3@m uk-align-center"> <div class="uk-width-1-3@m uk-align-center">
<!-- Validate form --> <!-- Validate form -->
<div id="registerForm"> <div id="registerForm">

View File

@ -53,7 +53,7 @@
<div class="uk-width-1-1@m uk-width-1-1@s uk-text-center"> <div class="uk-width-1-1@m uk-width-1-1@s uk-text-center">
<!-- <h3 class="uk-h3">Create an account</h3> --> <!-- <h3 class="uk-h3">Create an account</h3> -->
<div class="middle-box text-center loginscreen animated fadeInDown "> <div class="middle-box text-center loginscreen animated fadeInDown ">
<h3 class="uk-h4 uk-text-success">You have successfully registered!</h3> <h3 class="uk-h4 uk-text-success">Your account has been successfully activated!</h3>
<div class="uk-width-1-3@m uk-align-center"> <div class="uk-width-1-3@m uk-align-center">
<%--<p>Please click <a href="http://beta.services.openaire.eu/uoa-user-management/openid_connect_login">here</a> to login.</p>--%> <%--<p>Please click <a href="http://beta.services.openaire.eu/uoa-user-management/openid_connect_login">here</a> to login.</p>--%>
</div> </div>