From 69b0ad5ce840c933542871fe7975ef0a44ef3591 Mon Sep 17 00:00:00 2001 From: Nicolas Micoud Date: Sat, 15 Dec 2018 16:50:08 +0100 Subject: [PATCH] IDEMPIERE-3780 AD_User.IsNoExpire to override MAX_INACTIVE_PERIOD_DAY --- .../oracle/201808311200_IDEMPIERE-3780.sql | 26 +++++++++++++++++++ .../201808311200_IDEMPIERE-3780.sql | 23 ++++++++++++++++ .../src/org/compiere/model/I_AD_User.java | 9 +++++++ .../src/org/compiere/model/X_AD_User.java | 25 +++++++++++++++++- .../src/org/compiere/util/Login.java | 4 +-- 5 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 migration/i6.1/oracle/201808311200_IDEMPIERE-3780.sql create mode 100644 migration/i6.1/postgresql/201808311200_IDEMPIERE-3780.sql diff --git a/migration/i6.1/oracle/201808311200_IDEMPIERE-3780.sql b/migration/i6.1/oracle/201808311200_IDEMPIERE-3780.sql new file mode 100644 index 0000000000..bf60f99760 --- /dev/null +++ b/migration/i6.1/oracle/201808311200_IDEMPIERE-3780.sql @@ -0,0 +1,26 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- IDEMPIERE-3780 : AD_User.IsNoExpire to override MAX_INACTIVE_PERIOD_DAY +-- Aug 31, 2018 11:49:36 AM CEST +INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,PrintName,EntityType,AD_Element_UU) VALUES (203266,0,0,'Y',TO_DATE('2018-08-31 11:49:36','YYYY-MM-DD HH24:MI:SS'),0,TO_DATE('2018-08-31 11:49:36','YYYY-MM-DD HH24:MI:SS'),0,'IsNoExpire','No Expire','No Expire','D','86e9d8d5-35c5-4ba1-85d3-d674d8f48a2f') +; + +-- Aug 31, 2018 11:50:17 AM CEST +INSERT INTO AD_Column (AD_Column_ID,Version,Name,AD_Table_ID,ColumnName,DefaultValue,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure,FKConstraintType) VALUES (213690,0,'No Expire',114,'IsNoExpire','N',1,'N','N','Y','N','N',0,'N',20,0,0,'Y',TO_DATE('2018-08-31 11:50:17','YYYY-MM-DD HH24:MI:SS'),0,TO_DATE('2018-08-31 11:50:17','YYYY-MM-DD HH24:MI:SS'),0,203266,'Y','N','D','N','N','N','Y','27a982d2-604b-4efe-982c-6e5004e62072','N',0,'N','Y','N') +; + +-- Aug 31, 2018 11:50:19 AM CEST +ALTER TABLE AD_User ADD IsNoExpire CHAR(1) DEFAULT 'N' CHECK (IsNoExpire IN ('Y','N')) NOT NULL +; + +-- Aug 31, 2018 11:50:38 AM CEST +INSERT INTO AD_Field (AD_Field_ID,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan) VALUES (205827,'No Expire',118,213690,'Y',1,440,'N','N','N','N',0,0,'Y',TO_DATE('2018-08-31 11:50:38','YYYY-MM-DD HH24:MI:SS'),0,TO_DATE('2018-08-31 11:50:38','YYYY-MM-DD HH24:MI:SS'),0,'N','Y','D','f96b4141-f3b9-45da-917f-23f9ddc80071','Y',3220,2,2) +; + +-- Aug 31, 2018 11:51:05 AM CEST +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=420, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=2, ColumnSpan=1, IsToolbarButton=NULL,Updated=TO_DATE('2018-08-31 11:51:05','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=205827 +; + +SELECT register_migration_script('201808311200_IDEMPIERE-3780.sql') FROM dual +; \ No newline at end of file diff --git a/migration/i6.1/postgresql/201808311200_IDEMPIERE-3780.sql b/migration/i6.1/postgresql/201808311200_IDEMPIERE-3780.sql new file mode 100644 index 0000000000..c3457b487f --- /dev/null +++ b/migration/i6.1/postgresql/201808311200_IDEMPIERE-3780.sql @@ -0,0 +1,23 @@ +-- IDEMPIERE-3780 : AD_User.IsNoExpire to override MAX_INACTIVE_PERIOD_DAY +-- Aug 31, 2018 11:49:36 AM CEST +INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,PrintName,EntityType,AD_Element_UU) VALUES (203266,0,0,'Y',TO_TIMESTAMP('2018-08-31 11:49:36','YYYY-MM-DD HH24:MI:SS'),0,TO_TIMESTAMP('2018-08-31 11:49:36','YYYY-MM-DD HH24:MI:SS'),0,'IsNoExpire','No Expire','No Expire','D','86e9d8d5-35c5-4ba1-85d3-d674d8f48a2f') +; + +-- Aug 31, 2018 11:50:17 AM CEST +INSERT INTO AD_Column (AD_Column_ID,Version,Name,AD_Table_ID,ColumnName,DefaultValue,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure,FKConstraintType) VALUES (213690,0,'No Expire',114,'IsNoExpire','N',1,'N','N','Y','N','N',0,'N',20,0,0,'Y',TO_TIMESTAMP('2018-08-31 11:50:17','YYYY-MM-DD HH24:MI:SS'),0,TO_TIMESTAMP('2018-08-31 11:50:17','YYYY-MM-DD HH24:MI:SS'),0,203266,'Y','N','D','N','N','N','Y','27a982d2-604b-4efe-982c-6e5004e62072','N',0,'N','Y','N') +; + +-- Aug 31, 2018 11:50:19 AM CEST +ALTER TABLE AD_User ADD COLUMN IsNoExpire CHAR(1) DEFAULT 'N' CHECK (IsNoExpire IN ('Y','N')) NOT NULL +; + +-- Aug 31, 2018 11:50:38 AM CEST +INSERT INTO AD_Field (AD_Field_ID,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan) VALUES (205827,'No Expire',118,213690,'Y',1,440,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2018-08-31 11:50:38','YYYY-MM-DD HH24:MI:SS'),0,TO_TIMESTAMP('2018-08-31 11:50:38','YYYY-MM-DD HH24:MI:SS'),0,'N','Y','D','f96b4141-f3b9-45da-917f-23f9ddc80071','Y',3220,2,2) +; + +-- Aug 31, 2018 11:51:05 AM CEST +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=420, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=2, ColumnSpan=1, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-08-31 11:51:05','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=205827 +; + +SELECT register_migration_script('201808311200_IDEMPIERE-3780.sql') FROM dual +; \ No newline at end of file diff --git a/org.adempiere.base/src/org/compiere/model/I_AD_User.java b/org.adempiere.base/src/org/compiere/model/I_AD_User.java index ec433a0230..73697e0514 100644 --- a/org.adempiere.base/src/org/compiere/model/I_AD_User.java +++ b/org.adempiere.base/src/org/compiere/model/I_AD_User.java @@ -485,6 +485,15 @@ public interface I_AD_User */ public String getIsMenuAutoExpand(); + /** Column name IsNoExpire */ + public static final String COLUMNNAME_IsNoExpire = "IsNoExpire"; + + /** Set No Expire */ + public void setIsNoExpire (boolean IsNoExpire); + + /** Get No Expire */ + public boolean isNoExpire(); + /** Column name IsNoPasswordReset */ public static final String COLUMNNAME_IsNoPasswordReset = "IsNoPasswordReset"; diff --git a/org.adempiere.base/src/org/compiere/model/X_AD_User.java b/org.adempiere.base/src/org/compiere/model/X_AD_User.java index 0dad803eff..4e45ba1a2e 100644 --- a/org.adempiere.base/src/org/compiere/model/X_AD_User.java +++ b/org.adempiere.base/src/org/compiere/model/X_AD_User.java @@ -31,7 +31,7 @@ public class X_AD_User extends PO implements I_AD_User, I_Persistent /** * */ - private static final long serialVersionUID = 20181104L; + private static final long serialVersionUID = 20180831L; /** Standard Constructor */ public X_AD_User (Properties ctx, int AD_User_ID, String trxName) @@ -52,6 +52,8 @@ public class X_AD_User extends PO implements I_AD_User, I_Persistent // N setIsLocked (false); // 'N' + setIsNoExpire (false); +// N setIsNoPasswordReset (false); // 'N' setIsSalesLead (false); @@ -747,6 +749,27 @@ public class X_AD_User extends PO implements I_AD_User, I_Persistent return (String)get_Value(COLUMNNAME_IsMenuAutoExpand); } + /** Set No Expire. + @param IsNoExpire No Expire */ + public void setIsNoExpire (boolean IsNoExpire) + { + set_Value (COLUMNNAME_IsNoExpire, Boolean.valueOf(IsNoExpire)); + } + + /** Get No Expire. + @return No Expire */ + public boolean isNoExpire () + { + Object oo = get_Value(COLUMNNAME_IsNoExpire); + if (oo != null) + { + if (oo instanceof Boolean) + return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); + } + return false; + } + /** Set No Password Reset. @param IsNoPasswordReset No Password Reset */ public void setIsNoPasswordReset (boolean IsNoPasswordReset) diff --git a/org.adempiere.base/src/org/compiere/util/Login.java b/org.adempiere.base/src/org/compiere/util/Login.java index 9ca1beea23..860480a28a 100644 --- a/org.adempiere.base/src/org/compiere/util/Login.java +++ b/org.adempiere.base/src/org/compiere/util/Login.java @@ -1312,7 +1312,7 @@ public class Login if (minutes > MAX_ACCOUNT_LOCK_MINUTES) { boolean inactive = false; - if (MAX_INACTIVE_PERIOD_DAY > 0 && user.getDateLastLogin() != null) + if (MAX_INACTIVE_PERIOD_DAY > 0 && user.getDateLastLogin() != null && !user.isNoExpire()) { long days = (now - user.getDateLastLogin().getTime()) / (1000 * 60 * 60 * 24); if (days > MAX_INACTIVE_PERIOD_DAY) @@ -1331,7 +1331,7 @@ public class Login } } - if (MAX_INACTIVE_PERIOD_DAY > 0 && !user.isLocked() && user.getDateLastLogin() != null) + if (MAX_INACTIVE_PERIOD_DAY > 0 && !user.isLocked() && user.getDateLastLogin() != null && !user.isNoExpire()) { long days = (now - user.getDateLastLogin().getTime()) / (1000 * 60 * 60 * 24); if (days > MAX_INACTIVE_PERIOD_DAY)