IDEMPIERE-1672 create a user with name same exist user, make exist user can't log-in
This commit is contained in:
parent
9dccd57617
commit
89ba2d67e3
|
@ -887,20 +887,34 @@ public class MUser extends X_AD_User
|
||||||
if (newRecord || super.getValue() == null || is_ValueChanged("Value"))
|
if (newRecord || super.getValue() == null || is_ValueChanged("Value"))
|
||||||
setValue(super.getValue());
|
setValue(super.getValue());
|
||||||
|
|
||||||
boolean email_login = MSysConfig.getBooleanValue(MSysConfig.USE_EMAIL_FOR_LOGIN, false);
|
if (getPassword() != null && getPassword().length() > 0) {
|
||||||
if (email_login && getPassword() != null && getPassword().length() > 0) {
|
boolean email_login = MSysConfig.getBooleanValue(MSysConfig.USE_EMAIL_FOR_LOGIN, false);
|
||||||
// email is mandatory for users with password
|
if (email_login) {
|
||||||
if (getEMail() == null || getEMail().length() == 0) {
|
// email is mandatory for users with password
|
||||||
log.saveError("SaveError", Msg.getMsg(getCtx(), "FillMandatory") + Msg.getElement(getCtx(), COLUMNNAME_EMail) + " - " + toString());
|
if (getEMail() == null || getEMail().length() == 0) {
|
||||||
return false;
|
log.saveError("SaveError", Msg.getMsg(getCtx(), "FillMandatory") + Msg.getElement(getCtx(), COLUMNNAME_EMail) + " - " + toString());
|
||||||
}
|
return false;
|
||||||
// email with password must be unique on the same tenant
|
}
|
||||||
int cnt = DB.getSQLValue(get_TrxName(),
|
// email with password must be unique on the same tenant
|
||||||
"SELECT COUNT(*) FROM AD_User WHERE Password IS NOT NULL AND EMail=? AND AD_Client_ID=? AND AD_User_ID!=?",
|
int cnt = DB.getSQLValue(get_TrxName(),
|
||||||
getEMail(), getAD_Client_ID(), getAD_User_ID());
|
"SELECT COUNT(*) FROM AD_User WHERE Password IS NOT NULL AND EMail=? AND AD_Client_ID=? AND AD_User_ID!=?",
|
||||||
if (cnt > 0) {
|
getEMail(), getAD_Client_ID(), getAD_User_ID());
|
||||||
log.saveError("SaveError", Msg.getMsg(getCtx(), DBException.SAVE_ERROR_NOT_UNIQUE_MSG, true) + Msg.getElement(getCtx(), COLUMNNAME_EMail));
|
if (cnt > 0) {
|
||||||
return false;
|
log.saveError("SaveError", Msg.getMsg(getCtx(), DBException.SAVE_ERROR_NOT_UNIQUE_MSG, true) + Msg.getElement(getCtx(), COLUMNNAME_EMail));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// IDEMPIERE-1672 check duplicate name in client
|
||||||
|
String nameToValidate = getLDAPUser();
|
||||||
|
if (Util.isEmpty(nameToValidate))
|
||||||
|
nameToValidate = getName();
|
||||||
|
int cnt = DB.getSQLValue(get_TrxName(),
|
||||||
|
"SELECT COUNT(*) FROM AD_User WHERE Password IS NOT NULL AND COALESCE(LDAPUser,Name)=? AND AD_Client_ID=? AND AD_User_ID!=?",
|
||||||
|
nameToValidate, getAD_Client_ID(), getAD_User_ID());
|
||||||
|
if (cnt > 0) {
|
||||||
|
log.saveError("SaveError", Msg.getMsg(getCtx(), DBException.SAVE_ERROR_NOT_UNIQUE_MSG, true) + Msg.getElement(getCtx(), COLUMNNAME_Name) + " / " + Msg.getElement(getCtx(), COLUMNNAME_LDAPUser));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue