diff --git a/YACOSWeb/WebContent/WEB-INF/classes/messages.properties b/YACOSWeb/WebContent/WEB-INF/classes/messages.properties
index 82450c2..7cdca7a 100644
--- a/YACOSWeb/WebContent/WEB-INF/classes/messages.properties
+++ b/YACOSWeb/WebContent/WEB-INF/classes/messages.properties
@@ -65,6 +65,8 @@ form.register.user.lastName=Last Name
form.register.user.organization=Organization
form.register.error.loginTooShort=Login must be at least 3 characters long
form.register.error.loginInvalid=The login can only contain characters, dot, underscore and must start with a character
+form.register.error.emailEmpty=Email is required
+form.register.error.emailInvalid=Syntax of email is invalid, minimize characters if necessary
form.register.error.passwordsDontMatches=The password doesn't match the confirmation
form.register.error.firstNameEmpty=First name is required
form.register.error.lastNameEmpty=Last name is required
diff --git a/YACOSWeb/WebContent/WEB-INF/jsp/registerUser.jsp b/YACOSWeb/WebContent/WEB-INF/jsp/registerUser.jsp
index afbe812..c3e04c7 100644
--- a/YACOSWeb/WebContent/WEB-INF/jsp/registerUser.jsp
+++ b/YACOSWeb/WebContent/WEB-INF/jsp/registerUser.jsp
@@ -4,19 +4,19 @@
-
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
"/>
diff --git a/YACOSWeb/WebContent/WEB-INF/yacos-servlet.xml b/YACOSWeb/WebContent/WEB-INF/yacos-servlet.xml
index ae852fa..9e544e2 100644
--- a/YACOSWeb/WebContent/WEB-INF/yacos-servlet.xml
+++ b/YACOSWeb/WebContent/WEB-INF/yacos-servlet.xml
@@ -87,7 +87,12 @@
value="org.yacos.web.system.form.FormUser" />
-
+
+
+
+
+
-
diff --git a/YACOSWeb/WebContent/login.jsp b/YACOSWeb/WebContent/login.jsp
index e23a23e..9b2c283 100644
--- a/YACOSWeb/WebContent/login.jsp
+++ b/YACOSWeb/WebContent/login.jsp
@@ -4,11 +4,11 @@
-
diff --git a/YACOSWeb/WebContent/stylesheets/base.css b/YACOSWeb/WebContent/stylesheets/base.css
index a0f8829..693a400 100644
--- a/YACOSWeb/WebContent/stylesheets/base.css
+++ b/YACOSWeb/WebContent/stylesheets/base.css
@@ -21,8 +21,13 @@ body {
position: relative;
}
-.errorMessage {
- color:red;
+.login_error {
+ color: #ff0000;
+ font-size: 10px;
+}
+
+.formError{
+ color: #ff0000;
font-size: 10px;
}
diff --git a/YACOSWeb/src/org/yacos/web/system/validation/UserValidator.java b/YACOSWeb/src/org/yacos/web/system/validation/UserValidator.java
index a9c1f0f..a722714 100644
--- a/YACOSWeb/src/org/yacos/web/system/validation/UserValidator.java
+++ b/YACOSWeb/src/org/yacos/web/system/validation/UserValidator.java
@@ -20,8 +20,9 @@ public class UserValidator implements Validator {
/**
* @see org.springframework.validation.Validator#supports(java.lang.Class)
*/
+ @SuppressWarnings("unchecked")
public boolean supports(Class commandClass) {
- return FormUser.class.equals(commandClass);
+ return commandClass.isAssignableFrom(FormUser.class);
}
/**
@@ -30,23 +31,47 @@ public class UserValidator implements Validator {
public void validate(Object commandObject, Errors errors) {
FormUser userCommand = (FormUser) commandObject;
- // User login
- Pattern loginPattern = Pattern.compile("^[a-zA-Z][a-zA-Z0-9\\._-]+$");
- Matcher loginMatcher = loginPattern.matcher(userCommand.getLogin());
- if(loginMatcher.matches()){
- errors.rejectValue("login", "form.register.error.loginInvalid");
- }
- if(userCommand.getLogin().length()<3){
- errors.rejectValue("login", "form.register.error.loginTooShort");
- }
+ validateLogin(userCommand.getLogin(), errors);
+ validateEmail(userCommand.getEmail(), errors);
+ validatePassword(userCommand, errors);
- ValidationUtils.rejectIfEmptyOrWhitespace(errors, userCommand.getPassword(), "form.register.error.passwordEmpty");
+ // FIRSTNAME & LASTNAME VALIDATOR
+ ValidationUtils.rejectIfEmptyOrWhitespace(errors, "firstName", "form.register.error.firstNameEmpty");
+ ValidationUtils.rejectIfEmptyOrWhitespace(errors, "lastName", "form.register.error.lastNameEmpty");
+ }
+
+ // PASSWORD VALIDATOR
+ public void validatePassword(FormUser userCommand, Errors errors){
+ ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "form.register.error.passwordEmpty");
if(userCommand.passwordWasModified() && (! userCommand.passwordsMatches())){
errors.rejectValue("password", "form.register.error.passwordsDontMatches");
}
+ }
+
+ // EMAIL VALIDATOR
+ public void validateEmail(String email, Errors errors){
+ Pattern emailPattern = Pattern.compile("^[a-z0-9._-]+@[a-z0-9._-]{2,}[.][a-z]{2,4}$"); // Regex
+ Matcher emailMatcher = emailPattern.matcher(email);
- ValidationUtils.rejectIfEmptyOrWhitespace(errors, userCommand.getFirstName(), "form.register.error.firstNameEmpty");
- ValidationUtils.rejectIfEmptyOrWhitespace(errors, userCommand.getLastName(), "form.register.error.lastNameEmpty");
+ if(!emailMatcher.matches()){
+ errors.rejectValue("email", "form.register.error.emailInvalid");
+ }
+ ValidationUtils.rejectIfEmpty(errors, "email", "form.register.error.emailEmpty");
+ }
+
+ // LOGIN VALIDATOR
+ public void validateLogin(String login, Errors errors){
+ // 3 caractere mini, commence par un caractere
+ Pattern loginPattern = Pattern.compile("^[a-zA-Z][a-zA-Z0-9._-]+$"); //Regex
+ Matcher loginMatcher = loginPattern.matcher(login);
+
+ if(!loginMatcher.matches()){
+ errors.rejectValue("login", "form.register.error.loginInvalid");
+ }
+
+ if(login.length()<3){
+ errors.rejectValue("login", "form.register.error.loginTooShort");
+ }
}
}