IDEMPIERE-3696 Implementing warning to encourage user to change their password before it is expired

This commit is contained in:
Nicolas Micoud 2018-04-25 13:31:59 +02:00
parent 667aba2de6
commit d28dec8f32
4 changed files with 49 additions and 2 deletions

View File

@ -0,0 +1,18 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-3696 Implementing warning to encourage user to change their password before it is expired
-- Apr 24, 2018 9:44:15 PM CEST
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Your password will expire in {0} days',0,0,'Y',TO_DATE('2018-04-24 21:44:15','YYYY-MM-DD HH24:MI:SS'),0,TO_DATE('2018-04-24 21:44:15','YYYY-MM-DD HH24:MI:SS'),0,200453,'YourPasswordWillExpireInDays','D','85f74e09-67bf-4044-a276-a0bb07bb73f9')
;
-- Apr 24, 2018 9:44:22 PM CEST
UPDATE AD_Message SET EntityType='D',Updated=TO_DATE('2018-04-24 21:44:22','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Message_ID=200453
;
-- Apr 24, 2018 9:44:44 PM CEST
INSERT INTO AD_SysConfig (AD_SysConfig_ID,AD_Client_ID,AD_Org_ID,Created,Updated,CreatedBy,UpdatedBy,IsActive,Name,Value,Description,EntityType,ConfigurationLevel,AD_SysConfig_UU) VALUES (200117,0,0,TO_DATE('2018-04-24 21:44:44','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2018-04-24 21:44:44','YYYY-MM-DD HH24:MI:SS'),0,0,'Y','USER_LOCKING_PASSWORD_NOTIFY_DAY','0','Define a period (before password is expired) where a popup will appears to encourage user to change its password','D','S','92d15407-ddc2-4100-b2ae-bdccca3098d6')
;
SELECT register_migration_script('201804242200_IDEMPIERE-3696.sql') FROM dual
;

View File

@ -0,0 +1,15 @@
-- IDEMPIERE-3696 Implementing warning to encourage user to change their password before it is expired
-- Apr 24, 2018 9:44:15 PM CEST
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Your password will expire in {0} days',0,0,'Y',TO_TIMESTAMP('2018-04-24 21:44:15','YYYY-MM-DD HH24:MI:SS'),0,TO_TIMESTAMP('2018-04-24 21:44:15','YYYY-MM-DD HH24:MI:SS'),0,200453,'YourPasswordWillExpireInDays','D','85f74e09-67bf-4044-a276-a0bb07bb73f9')
;
-- Apr 24, 2018 9:44:22 PM CEST
UPDATE AD_Message SET EntityType='D',Updated=TO_TIMESTAMP('2018-04-24 21:44:22','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Message_ID=200453
;
-- Apr 24, 2018 9:44:44 PM CEST
INSERT INTO AD_SysConfig (AD_SysConfig_ID,AD_Client_ID,AD_Org_ID,Created,Updated,CreatedBy,UpdatedBy,IsActive,Name,Value,Description,EntityType,ConfigurationLevel,AD_SysConfig_UU) VALUES (200117,0,0,TO_TIMESTAMP('2018-04-24 21:44:44','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2018-04-24 21:44:44','YYYY-MM-DD HH24:MI:SS'),0,0,'Y','USER_LOCKING_PASSWORD_NOTIFY_DAY','0','Define a period (before password is expired) where a popup will appears to encourage user to change its password','D','S','92d15407-ddc2-4100-b2ae-bdccca3098d6')
;
SELECT register_migration_script('201804242200_IDEMPIERE-3696.sql') FROM dual
;

View File

@ -42,7 +42,7 @@ public class MSysConfig extends X_AD_SysConfig
/**
*
*/
private static final long serialVersionUID = -2698648078997788547L;
private static final long serialVersionUID = 5886520708050807357L;
public static final String ADDRESS_VALIDATION = "ADDRESS_VALIDATION";
public static final String ALERT_SEND_ATTACHMENT_AS_XLS = "ALERT_SEND_ATTACHMENT_AS_XLS";
@ -149,6 +149,7 @@ public class MSysConfig extends X_AD_SysConfig
public static final String USER_LOCKING_MAX_INACTIVE_PERIOD_DAY = "USER_LOCKING_MAX_INACTIVE_PERIOD_DAY";
public static final String USER_LOCKING_MAX_LOGIN_ATTEMPT = "USER_LOCKING_MAX_LOGIN_ATTEMPT";
public static final String USER_LOCKING_MAX_PASSWORD_AGE_DAY = "USER_LOCKING_MAX_PASSWORD_AGE_DAY";
public static final String USER_LOCKING_PASSWORD_NOTIFY_DAY = "USER_LOCKING_PASSWORD_NOTIFY_DAY";
public static final String USER_PASSWORD_HASH = "USER_PASSWORD_HASH";
public static final String VALIDATE_MATCHING_TO_ORDERED_QTY = "VALIDATE_MATCHING_TO_ORDERED_QTY";
public static final String WEBUI_LOGOURL = "WEBUI_LOGOURL";

View File

@ -52,6 +52,7 @@ import org.compiere.util.KeyNamePair;
import org.compiere.util.Language;
import org.compiere.util.Login;
import org.compiere.util.Msg;
import org.compiere.util.TimeUtil;
import org.compiere.util.Util;
import org.zkoss.zhtml.Table;
import org.zkoss.zhtml.Td;
@ -84,7 +85,7 @@ public class RolePanel extends Window implements EventListener<Event>, Deferrabl
/**
*
*/
private static final long serialVersionUID = 4068073033610726196L;
private static final long serialVersionUID = 372661654078492488L;
protected LoginWindow wndLogin;
protected Login login;
@ -643,6 +644,18 @@ public class RolePanel extends Window implements EventListener<Event>, Deferrabl
return;
}
// See if a popup should encourage user to change its password
int notifyDay = MSysConfig.getIntValue(MSysConfig.USER_LOCKING_PASSWORD_NOTIFY_DAY, 0);
int pwdAgeDay = MSysConfig.getIntValue(MSysConfig.USER_LOCKING_MAX_PASSWORD_AGE_DAY, 0);
if (notifyDay > 0 && pwdAgeDay > 0) {
Timestamp limit = TimeUtil.addDays(MUser.get(Env.getCtx(), Env.getAD_User_ID(Env.getCtx())).getDatePasswordChanged(), pwdAgeDay);
Timestamp notifyAfter = TimeUtil.addDays(limit, -notifyDay);
Timestamp now = TimeUtil.getDay(null);
if (now.after(notifyAfter))
FDialog.warn(0, null, "", Msg.getMsg(Env.getCtx(), "YourPasswordWillExpireInDays", new Object[] {TimeUtil.getDaysBetween(now, limit)}));
}
wndLogin.loginCompleted();
// Elaine 2009/02/06 save preference to AD_Preference