diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VResetPassword.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VResetPassword.java index 175dfede91..2f38ec9f86 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VResetPassword.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/form/VResetPassword.java @@ -265,6 +265,13 @@ public class VResetPassword implements FormPanel, ActionListener, VetoableChange return; } } + if (MSysConfig.getBooleanValue(MSysConfig.CHANGE_PASSWORD_MUST_DIFFER, true)) + { + if (p_OldPassword.equals(p_NewPassword)) { + ADialog.error(windowNo, frame, "NewPasswordMustDiffer"); + return; + } + } } // new password confirm @@ -301,7 +308,15 @@ public class VResetPassword implements FormPanel, ActionListener, VetoableChange if (!Util.isEmpty(p_NewEMailUserPW)) user.setEMailUserPW(p_NewEMailUserPW); - user.saveEx(); + try { + user.saveEx(); + } + catch(Exception e) + { + ADialog.error(windowNo, frame, e.getLocalizedMessage()); + user.load(user.get_TrxName()); + return; + } clearForm(); ADialog.info(windowNo, frame, "RecordSaved"); return; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WResetPassword.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WResetPassword.java index e8cf4ae6ac..7063ff87fe 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WResetPassword.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WResetPassword.java @@ -16,6 +16,7 @@ package org.adempiere.webui.apps.form; import java.util.logging.Level; +import org.adempiere.exceptions.AdempiereException; import org.adempiere.webui.AdempiereIdGenerator; import org.adempiere.webui.component.Column; import org.adempiere.webui.component.ConfirmPanel; @@ -294,6 +295,12 @@ public class WResetPassword implements IFormController, EventListener, ValueChan if (!p_OldPassword.equals(user.getPassword())) throw new IllegalArgumentException(Msg.getMsg(Env.getCtx(), "OldPasswordNoMatch")); } + if (MSysConfig.getBooleanValue(MSysConfig.CHANGE_PASSWORD_MUST_DIFFER, true)) + { + if (p_OldPassword.equals(p_NewPassword)) { + throw new IllegalArgumentException(Msg.getMsg(Env.getCtx(), "NewPasswordMustDiffer")); + } + } } // new password confirm @@ -326,7 +333,14 @@ public class WResetPassword implements IFormController, EventListener, ValueChan if (!Util.isEmpty(p_NewEMailUserPW)) user.setEMailUserPW(p_NewEMailUserPW); - user.saveEx(); + try { + user.saveEx(); + } + catch(AdempiereException e) + { + user.load(user.get_TrxName()); + throw e; + } clearForm(); FDialog.info(form.getWindowNo(), form, "RecordSaved"); return;