IDEMPIERE-373 Implement User Locking - fix the default date password change and use translatable message
This commit is contained in:
parent
15ef6841da
commit
65d8b478f3
|
@ -0,0 +1,31 @@
|
|||
-- Sep 5, 2012 2:19:04 PM SGT
|
||||
-- IDEMPIERE-373 Implement User Locking
|
||||
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('E','User account ''{0}'' is locked, please contact the system administrator',200032,'D','4953cc21-e6db-40c6-bc8c-58f089e4786a','UserAccountLocked','Y',TO_DATE('2012-09-05 14:19:02','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_DATE('2012-09-05 14:19:02','YYYY-MM-DD HH24:MI:SS'))
|
||||
;
|
||||
|
||||
-- Sep 5, 2012 2:19:05 PM SGT
|
||||
-- IDEMPIERE-373 Implement User Locking
|
||||
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200032 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
|
||||
;
|
||||
|
||||
-- Sep 5, 2012 2:19:26 PM SGT
|
||||
-- IDEMPIERE-373 Implement User Locking
|
||||
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('E','Reached the maximum number of login attempts, user account ''{0}'' is locked',200033,'D','f8a4fc39-5346-4064-8f3a-436fcac03920','ReachedMaxLoginAttempts','Y',TO_DATE('2012-09-05 14:19:25','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_DATE('2012-09-05 14:19:25','YYYY-MM-DD HH24:MI:SS'))
|
||||
;
|
||||
|
||||
-- Sep 5, 2012 2:19:26 PM SGT
|
||||
-- IDEMPIERE-373 Implement User Locking
|
||||
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200033 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
|
||||
;
|
||||
|
||||
-- Sep 5, 2012 2:19:44 PM SGT
|
||||
-- IDEMPIERE-373 Implement User Locking
|
||||
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('E','Invalid User ID or Password (Login Attempts: {0} / {1})',200034,'D','77c2348b-0910-43aa-a6c0-f3c143a52de4','FailedLoginAttempt','Y',TO_DATE('2012-09-05 14:19:43','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_DATE('2012-09-05 14:19:43','YYYY-MM-DD HH24:MI:SS'))
|
||||
;
|
||||
|
||||
-- Sep 5, 2012 2:19:44 PM SGT
|
||||
-- IDEMPIERE-373 Implement User Locking
|
||||
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200034 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
|
||||
;
|
||||
|
||||
SELECT register_migration_script('902_IDEMPIERE-373_User_Locking.sql') FROM dual
|
|
@ -0,0 +1,31 @@
|
|||
-- Sep 5, 2012 2:19:04 PM SGT
|
||||
-- IDEMPIERE-373 Implement User Locking
|
||||
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('E','User account ''{0}'' is locked, please contact the system administrator',200032,'D','4953cc21-e6db-40c6-bc8c-58f089e4786a','UserAccountLocked','Y',TO_TIMESTAMP('2012-09-05 14:19:02','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_TIMESTAMP('2012-09-05 14:19:02','YYYY-MM-DD HH24:MI:SS'))
|
||||
;
|
||||
|
||||
-- Sep 5, 2012 2:19:05 PM SGT
|
||||
-- IDEMPIERE-373 Implement User Locking
|
||||
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200032 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
|
||||
;
|
||||
|
||||
-- Sep 5, 2012 2:19:26 PM SGT
|
||||
-- IDEMPIERE-373 Implement User Locking
|
||||
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('E','Reached the maximum number of login attempts, user account ''{0}'' is locked',200033,'D','f8a4fc39-5346-4064-8f3a-436fcac03920','ReachedMaxLoginAttempts','Y',TO_TIMESTAMP('2012-09-05 14:19:25','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_TIMESTAMP('2012-09-05 14:19:25','YYYY-MM-DD HH24:MI:SS'))
|
||||
;
|
||||
|
||||
-- Sep 5, 2012 2:19:26 PM SGT
|
||||
-- IDEMPIERE-373 Implement User Locking
|
||||
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200033 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
|
||||
;
|
||||
|
||||
-- Sep 5, 2012 2:19:44 PM SGT
|
||||
-- IDEMPIERE-373 Implement User Locking
|
||||
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('E','Invalid User ID or Password (Login Attempts: {0} / {1})',200034,'D','77c2348b-0910-43aa-a6c0-f3c143a52de4','FailedLoginAttempt','Y',TO_TIMESTAMP('2012-09-05 14:19:43','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_TIMESTAMP('2012-09-05 14:19:43','YYYY-MM-DD HH24:MI:SS'))
|
||||
;
|
||||
|
||||
-- Sep 5, 2012 2:19:44 PM SGT
|
||||
-- IDEMPIERE-373 Implement User Locking
|
||||
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200034 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
|
||||
;
|
||||
|
||||
SELECT register_migration_script('902_IDEMPIERE-373_User_Locking.sql') FROM dual
|
|
@ -1381,7 +1381,7 @@ public class Login
|
|||
if (days > MAX_INACTIVE_PERIOD_DAY)
|
||||
{
|
||||
user.setIsLocked(true);
|
||||
user.setDateAccountLocked(new Timestamp(new Date().getTime()));
|
||||
user.setDateAccountLocked(new Timestamp(now));
|
||||
if (!user.save())
|
||||
log.severe("Failed to lock user account");
|
||||
}
|
||||
|
@ -1415,7 +1415,7 @@ public class Login
|
|||
if (MAX_PASSWORD_AGE > 0 && !user.isNoPasswordReset())
|
||||
{
|
||||
if (user.getDatePasswordChanged() == null)
|
||||
user.setDatePasswordChanged(user.getUpdated());
|
||||
user.setDatePasswordChanged(new Timestamp(now));
|
||||
|
||||
long days = (now - user.getDatePasswordChanged().getTime()) / (1000 * 60 * 60 * 24);
|
||||
if (days > MAX_PASSWORD_AGE)
|
||||
|
@ -1475,7 +1475,7 @@ public class Login
|
|||
for (MUser user : users)
|
||||
{
|
||||
user.setFailedLoginCount(0);
|
||||
user.setDateLastLogin(new Timestamp(new Date().getTime()));
|
||||
user.setDateLastLogin(new Timestamp(now));
|
||||
if (!user.save())
|
||||
log.severe("Failed to update user record with date last login");
|
||||
}
|
||||
|
@ -1486,7 +1486,8 @@ public class Login
|
|||
{
|
||||
if (user.isLocked())
|
||||
{
|
||||
loginErrMsg = "User account '" + app_user + "' is locked, please contact the system administrator";
|
||||
// User account '{0}' is locked, please contact the system administrator
|
||||
loginErrMsg = Msg.getMsg(m_ctx, "UserAccountLocked", new Object[] {app_user});
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1496,12 +1497,14 @@ public class Login
|
|||
int MAX_LOGIN_ATTEMPT = MSysConfig.getIntValue(MSysConfig.USER_LOCKING_MAX_LOGIN_ATTEMPT, 0);
|
||||
if (MAX_LOGIN_ATTEMPT > 0 && count >= MAX_LOGIN_ATTEMPT)
|
||||
{
|
||||
loginErrMsg = "Reached the maximum number of login attempts, user account '" + app_user + "' is locked";
|
||||
// Reached the maximum number of login attempts, user account '{0}' is locked
|
||||
loginErrMsg = Msg.getMsg(m_ctx, "ReachedMaxLoginAttempts", new Object[] {app_user});
|
||||
reachMaxAttempt = true;
|
||||
}
|
||||
else if (MAX_LOGIN_ATTEMPT > 0)
|
||||
{
|
||||
loginErrMsg = "Invalid User ID or Password (Login Attempts: " + count + " / " + MAX_LOGIN_ATTEMPT + ")";
|
||||
// Invalid User ID or Password (Login Attempts: {0} / {1})
|
||||
loginErrMsg = Msg.getMsg(m_ctx, "FailedLoginAttempt", new Object[] {count, MAX_LOGIN_ATTEMPT});
|
||||
reachMaxAttempt = false;
|
||||
}
|
||||
else
|
||||
|
@ -1511,7 +1514,7 @@ public class Login
|
|||
|
||||
user.setFailedLoginCount(count);
|
||||
user.setIsLocked(reachMaxAttempt);
|
||||
user.setDateAccountLocked(user.isLocked() ? new Timestamp(new Date().getTime()) : null);
|
||||
user.setDateAccountLocked(user.isLocked() ? new Timestamp(now) : null);
|
||||
if (!user.save())
|
||||
log.severe("Failed to update user record with increase failed login count");
|
||||
}
|
||||
|
|
|
@ -626,26 +626,26 @@ public final class ALogin extends CDialog
|
|||
|
||||
if (Util.isEmpty(oldPassword))
|
||||
{
|
||||
statusBar.setStatusLine(Msg.getMsg(m_ctx, "@OldPasswordMandatory@"), true);
|
||||
statusBar.setStatusLine(Msg.getMsg(m_ctx, "OldPasswordMandatory"), true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Util.isEmpty(retypeNewPassword))
|
||||
{
|
||||
statusBar.setStatusLine(Msg.getMsg(m_ctx, "@NewPasswordConfirmMandatory@"), true);
|
||||
statusBar.setStatusLine(Msg.getMsg(m_ctx, "NewPasswordConfirmMandatory"), true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!newPassword.equals(retypeNewPassword))
|
||||
{
|
||||
statusBar.setStatusLine(Msg.getMsg(m_ctx, "@PasswordNotMatch@"), true);
|
||||
statusBar.setStatusLine(Msg.getMsg(m_ctx, "PasswordNotMatch"), true);
|
||||
return;
|
||||
}
|
||||
|
||||
String m_userPassword = new String(m_pwd);
|
||||
if (!oldPassword.equals(m_userPassword))
|
||||
{
|
||||
statusBar.setStatusLine(Msg.getMsg(m_ctx, "@OldPasswordNoMatch@"), true);
|
||||
statusBar.setStatusLine(Msg.getMsg(m_ctx, "OldPasswordNoMatch"), true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -200,16 +200,16 @@ public class ChangePasswordPanel extends Window implements EventListener<Event>
|
|||
String retypeNewPassword = txtRetypeNewPassword.getValue();
|
||||
|
||||
if (Util.isEmpty(oldPassword))
|
||||
throw new IllegalArgumentException(Msg.getMsg(m_ctx, "@OldPasswordMandatory@"));
|
||||
throw new IllegalArgumentException(Msg.getMsg(m_ctx, "OldPasswordMandatory"));
|
||||
|
||||
if (Util.isEmpty(retypeNewPassword))
|
||||
throw new IllegalArgumentException(Msg.getMsg(m_ctx, "@NewPasswordConfirmMandatory@"));
|
||||
throw new IllegalArgumentException(Msg.getMsg(m_ctx, "NewPasswordConfirmMandatory"));
|
||||
|
||||
if (!newPassword.equals(retypeNewPassword))
|
||||
throw new IllegalArgumentException(Msg.getMsg(m_ctx, "@PasswordNotMatch@"));
|
||||
throw new IllegalArgumentException(Msg.getMsg(m_ctx, "PasswordNotMatch"));
|
||||
|
||||
if (!oldPassword.equals(m_userPassword))
|
||||
throw new IllegalArgumentException(Msg.getMsg(m_ctx, "@OldPasswordNoMatch@"));
|
||||
throw new IllegalArgumentException(Msg.getMsg(m_ctx, "OldPasswordNoMatch"));
|
||||
|
||||
for (KeyNamePair clientKNPair : m_clientKNPairs)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue