MIFOSX-2022 To enable force-password reset, the value of no of days should be greater than zero.

This commit is contained in:
Chandrika
2015-05-13 20:48:28 -04:00
parent e8cfdcf865
commit 4b3e76afc2
4 changed files with 131 additions and 1 deletions
@@ -13,6 +13,7 @@ import javax.persistence.Entity;
import javax.persistence.Table;
import org.mifosplatform.infrastructure.core.api.JsonCommand;
import org.mifosplatform.infrastructure.security.exception.ForcePasswordResetException;
import org.springframework.data.jpa.domain.AbstractPersistable;
@Entity
@@ -72,12 +73,21 @@ public class GlobalConfigurationProperty extends AbstractPersistable<Long> {
}
final String valueParamName = "value";
final Long previousValue = this.value;
if (command.isChangeInLongParameterNamed(valueParamName, this.value)) {
final Long newValue = command.longValueOfParameterNamed(valueParamName);
actualChanges.put(valueParamName, newValue);
this.value = newValue;
}
final String passwordPropertyName = "force-password-reset-days";
if(this.name.equalsIgnoreCase(passwordPropertyName)){
if(this.enabled == true && command.hasParameter(valueParamName) && this.value == 0 ||
this.enabled == true && !command.hasParameter(valueParamName) && previousValue == 0){
throw new ForcePasswordResetException();
}
}
return actualChanges;
}
@@ -0,0 +1,17 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.mifosplatform.infrastructure.security.exception;
import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException;
public class ForcePasswordResetException extends AbstractPlatformDomainRuleException {
public ForcePasswordResetException(){
super("error.msg.password.reset.days.value.must.be.greater.than.zero" , "For enabling 'Force Password Reset Days' configuration , the value (number of days after which a user is forced to reset his password) must be set to a number greater than 0.");
}
}