Skip to content

Commit

Permalink
Merge pull request #26 from nicolasmoreau/dev
Browse files Browse the repository at this point in the history
bugs correction : password / verification password mismatch was not c…
  • Loading branch information
nicolasmoreau committed Aug 7, 2015
2 parents e3e2953 + 5920e59 commit 601ae0e
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.vamdc.portal.session.security;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.In;
Expand Down Expand Up @@ -38,7 +41,11 @@ public void register()
new RunAsOperation() {
@Override
public void execute() {
if (!identityManager.userExists(username)){
if(password.equals(verifyPassword) == false){
throw new IdentityManagementException("Password and verification password do not match.");
}else if(isValidEmail() == false){
throw new IdentityManagementException("Email address is not valid.");
} else if (!identityManager.userExists(username)){
identityManager.createUser(username,password);
}else{
throw new IdentityManagementException("User #{register.username} already exists!");
Expand All @@ -53,6 +60,12 @@ public void execute() {
}

}

private Boolean isValidEmail(){
Pattern pattern = Pattern.compile("^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$", Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(email);
return matcher.find();
}


@Observer(JpaIdentityStore.EVENT_PRE_PERSIST_USER)
Expand Down

0 comments on commit 601ae0e

Please sign in to comment.