Here's the code i wrote :
int notifyDay = MSysConfig.getIntValue(MSysConfig.USER_LOCKING_MAX_PASSWORD_NOTIFY_DAY, 0);
int pwdAgeDay = MSysConfig.getIntValue(MSysConfig.USER_LOCKING_MAX_PASSWORD_AGE_DAY, 0);
if (notifyDay > 0 && pwdAgeDay > 0) {
int userID = Env.getAD_User_ID(Env.getCtx());
Timestamp limit = TimeUtil.addDays(MUser.get(Env.getCtx(), userID).getDatePasswordChanged(), pwdAgeDay);
System.out.println("limit = " + limit);
Timestamp notifyAfter = TimeUtil.addDays(limit, -notifyDay);
System.out.println("notifyAfter = " + notifyAfter);
Timestamp now = TimeUtil.getDay(null);
System.out.println("now = " + now);
if (now.after(notifyAfter)) {
int nbDays = TimeUtil.getDaysBetween(now, limit);
FDialog.warn(0, null, "", Msg.getMsg(Env.getCtx(), "YourPasswordWillExpireInDays", new Object[] {nbDays}));
}
}
I try to use it on DefaultDesktop, RolePanel, AdempiereWebUI, and in all cases, the popup is shown, but when clicking on the "ok" button, the system just hangs.
Another option would be to use broadcast messages but i see 2 negative points :
- ATM, we can't just use BM with a simple text (we have to pass a AD_Message_ID)
- Not sure keeping in base a trace of all BM is useful
So, is there a good practice i could follow to display a popup right after user has logged in ?
Thanks,