Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make email's uniqueness enforcement by oxTrust optional #1371 #1375

Merged
merged 1 commit into from Nov 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -485,7 +485,7 @@ public void validateEmail(FacesContext context, UIComponent component, Object va
}

GluuCustomPerson gluuCustomPerson = personService.getPersonByEmail(email);
if (gluuCustomPerson != null) {
if (gluuCustomPerson != null && appConfiguration.getEnforceEmailUniqueness()) {
FacesMessage message = new FacesMessage("Email Address Already Registered.");
message.setSeverity(FacesMessage.SEVERITY_ERROR);
throw new ValidatorException(message);
Expand Down
Expand Up @@ -353,26 +353,35 @@ public String save() throws Exception {
return OxTrustConstants.RESULT_FAILURE;
}
if (!update) {

if (!userNameIsUniqAtCreationTime(this.person.getUid())) {
facesMessages.add(FacesMessage.SEVERITY_ERROR, "#{msg['UpdatePersonAction.faileAddUserUidExist']} %s",
this.person.getUid());
return OxTrustConstants.RESULT_FAILURE;
}
if (!userEmailIsUniqAtCreationTime(this.person.getAttribute(MAIL))) {
facesMessages.add(FacesMessage.SEVERITY_ERROR,
"#{msg['UpdatePersonAction.faileUpdateUserMailidExist']} %s", this.person.getAttribute(MAIL));
return OxTrustConstants.RESULT_FAILURE;
if (appConfiguration.getEnforceEmailUniqueness()) {
if (!userEmailIsUniqAtCreationTime(this.person.getAttribute(MAIL))) {
facesMessages.add(FacesMessage.SEVERITY_ERROR,
"#{msg['UpdatePersonAction.faileUpdateUserMailidExist']} %s",
this.person.getAttribute(MAIL));
return OxTrustConstants.RESULT_FAILURE;
}
}

} else {

if (!userNameIsUniqAtEditionTime(this.person.getUid())) {
facesMessages.add(FacesMessage.SEVERITY_ERROR, "#{msg['UpdatePersonAction.faileAddUserUidExist']} %s",
this.person.getUid());
return OxTrustConstants.RESULT_FAILURE;
}
if (!userEmailIsUniqAtEditionTime(this.person.getAttribute(MAIL))) {
facesMessages.add(FacesMessage.SEVERITY_ERROR,
"#{msg['UpdatePersonAction.faileUpdateUserMailidExist']} %s", this.person.getAttribute(MAIL));
return OxTrustConstants.RESULT_FAILURE;
if (appConfiguration.getEnforceEmailUniqueness()) {
if (!userEmailIsUniqAtEditionTime(this.person.getAttribute(MAIL))) {
facesMessages.add(FacesMessage.SEVERITY_ERROR,
"#{msg['UpdatePersonAction.faileUpdateUserMailidExist']} %s",
this.person.getAttribute(MAIL));
return OxTrustConstants.RESULT_FAILURE;
}
}
}

Expand Down
Expand Up @@ -151,10 +151,12 @@ public String show() {

public String update() {
try {
if (!userEmailIsUniqAtEditionTime(this.person.getAttribute("mail"))) {
facesMessages.add(FacesMessage.SEVERITY_ERROR,
"#{msg['UpdatePersonAction.faileUpdateUserMailidExist']} %s", person.getMail());
return OxTrustConstants.RESULT_FAILURE;
if (appConfiguration.getEnforceEmailUniqueness()) {
if (!userEmailIsUniqAtEditionTime(this.person.getAttribute("mail"))) {
facesMessages.add(FacesMessage.SEVERITY_ERROR,
"#{msg['UpdatePersonAction.faileUpdateUserMailidExist']} %s", person.getMail());
return OxTrustConstants.RESULT_FAILURE;
}
}
if (this.imapData != null) {
List<GluuCustomAttribute> customAttributes = this.person.getCustomAttributes();
Expand All @@ -175,7 +177,8 @@ public String update() {
externalUpdateUserService.executeExternalUpdateUserMethods(this.person);
}
personService.updatePerson(this.person);
oxTrustAuditService.audit(this.person.getInum()+ " **"+this.person.getDisplayName()+"** PROFILE UPDATED",
oxTrustAuditService.audit(
this.person.getInum() + " **" + this.person.getDisplayName() + "** PROFILE UPDATED",
identity.getUser(),
(HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest());
if (runScript) {
Expand Down
Expand Up @@ -627,6 +627,11 @@
"id": "authenticationRecaptchaEnabled",
"description": "Boolean value specifying whether to enable Recaptcha on authentication.",
"type": "boolean"
},
"enforceEmailUniqueness": {
"id": "enforceEmailUniqueness",
"description": "Boolean value specifying whether to enforce email uniqueness on oxtrust side.",
"type": "boolean"
}
},
"required": [
Expand Down Expand Up @@ -726,6 +731,7 @@
"disableJdkLogger",
"cleanServiceInterval",
"passwordResetRequestExpirationTime",
"authenticationRecaptchaEnabled"
"authenticationRecaptchaEnabled",
"enforceEmailUniqueness"
]
}