public inbox for [email protected]  
help / color / mirror / Atom feed
[pgAdmin][RM-6120]: Adding/updating user should not allow to add an older date in account expires.
6+ messages / 3 participants
[nested] [flat]

* [pgAdmin][RM-6120]: Adding/updating user should not allow to add an older date in account expires.
@ 2021-01-14 05:58  Nikhil Mohite <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Nikhil Mohite @ 2021-01-14 05:58 UTC (permalink / raw)
  To: pgadmin-hackers

Hi Team,

Please find the attached patch for RM-6120
<https://redmine.postgresql.org/issues/6120;: Adding/updating user should
not allow to add an older date in account expires.
Added UI validation if a user enters the account expiration date manually.

-- 
*Thanks & Regards,*
*Nikhil Mohite*
*Software Engineer.*
*EDB Postgres* <https://www.enterprisedb.com/;
*Mob.No: +91-7798364578.*


Attachments:

  [application/octet-stream] RM_6120.patch (1.6K, 3-RM_6120.patch)
  download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/roles/static/js/role.js b/web/pgadmin/browser/server_groups/servers/roles/static/js/role.js
index 68909fd8..2f957f53 100644
--- a/web/pgadmin/browser/server_groups/servers/roles/static/js/role.js
+++ b/web/pgadmin/browser/server_groups/servers/roles/static/js/role.js
@@ -562,6 +562,29 @@ define('pgadmin.node.role', [
             }
           }
 
+          //Check Account expiration should not be less that current selected date.
+          let currdate = null;
+          let oldDate = null;
+          if(this.get('rolvaliduntil') != this.origSessAttrs.rolvaliduntil && this.get('rolvaliduntil') != '' && this.origSessAttrs.rolvaliduntil != 'infinity') {
+            currdate = new Date(this.get('rolvaliduntil'));
+            oldDate = new Date(this.origSessAttrs.rolvaliduntil);
+          } else if (this.origSessAttrs.rolvaliduntil == 'infinity') {
+            if(this.get('rolvaliduntil') == '') {
+              let $el = this.panelEl.find('.datetimepicker-input');
+              currdate = $el.data('datetimepicker').date().clone()._d;
+            } else {
+              currdate = new Date(this.get('rolvaliduntil'));
+            }
+            oldDate = new Date();
+            oldDate.setHours(0,0,0,0);
+          }
+
+          if(currdate < oldDate) {
+            err['rolvaliduntil'] = gettext('Account expiration date can’t be older than current date');
+            errmsg = gettext('Account expiration date can’t be older than current date');
+          }
+
+
           this.errorModel.clear().set(err);
 
           if (_.size(err)) {


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [pgAdmin][RM-6120]: Adding/updating user should not allow to add an older date in account expires.
@ 2021-01-14 08:17  Akshay Joshi <[email protected]>
  parent: Nikhil Mohite <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Akshay Joshi @ 2021-01-14 08:17 UTC (permalink / raw)
  To: Nikhil Mohite <[email protected]>; +Cc: pgadmin-hackers

Thanks, patch applied.

On Thu, Jan 14, 2021 at 11:28 AM Nikhil Mohite <
[email protected]> wrote:

> Hi Team,
>
> Please find the attached patch for RM-6120
> <https://redmine.postgresql.org/issues/6120;: Adding/updating user should
> not allow to add an older date in account expires.
> Added UI validation if a user enters the account expiration date manually.
>
> --
> *Thanks & Regards,*
> *Nikhil Mohite*
> *Software Engineer.*
> *EDB Postgres* <https://www.enterprisedb.com/;
> *Mob.No: +91-7798364578.*
>


-- 
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Principal Software Architect*
*EDB Postgres <http://edbpostgres.com>*

*Mobile: +91 976-788-8246*


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [pgAdmin][RM-6120]: Adding/updating user should not allow to add an older date in account expires.
@ 2021-01-14 09:08  Dave Page <[email protected]>
  parent: Akshay Joshi <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Dave Page @ 2021-01-14 09:08 UTC (permalink / raw)
  To: Akshay Joshi <[email protected]>; +Cc: Nikhil Mohite <[email protected]>; pgadmin-hackers

On Thu, Jan 14, 2021 at 8:18 AM Akshay Joshi <[email protected]>
wrote:

> Thanks, patch applied.
>
> On Thu, Jan 14, 2021 at 11:28 AM Nikhil Mohite <
> [email protected]> wrote:
>
>> Hi Team,
>>
>> Please find the attached patch for RM-6120
>> <https://redmine.postgresql.org/issues/6120;: Adding/updating user
>> should not allow to add an older date in account expires.
>> Added UI validation if a user enters the account expiration date manually.
>>
>
I think this needs to be reverted (and the UI fixed to allow an older date
to be selected).

Selecting a past expiry date is a perfectly valid way to create an account
that is effectively locked, for example, to allow pre-creation of roles for
staff that are yet to join.

PostgreSQL doesn't prevent this - why should we?

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EDB: http://www.enterprisedb.com


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [pgAdmin][RM-6120]: Adding/updating user should not allow to add an older date in account expires.
@ 2021-01-14 09:22  Akshay Joshi <[email protected]>
  parent: Dave Page <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Akshay Joshi @ 2021-01-14 09:22 UTC (permalink / raw)
  To: Nikhil Mohite <[email protected]>; +Cc: pgadmin-hackers; Dave Page <[email protected]>

Hi Nikhil

On Thu, Jan 14, 2021 at 2:38 PM Dave Page <[email protected]> wrote:

>
>
> On Thu, Jan 14, 2021 at 8:18 AM Akshay Joshi <
> [email protected]> wrote:
>
>> Thanks, patch applied.
>>
>> On Thu, Jan 14, 2021 at 11:28 AM Nikhil Mohite <
>> [email protected]> wrote:
>>
>>> Hi Team,
>>>
>>> Please find the attached patch for RM-6120
>>> <https://redmine.postgresql.org/issues/6120;: Adding/updating user
>>> should not allow to add an older date in account expires.
>>> Added UI validation if a user enters the account expiration date
>>> manually.
>>>
>>
> I think this needs to be reverted (and the UI fixed to allow an older date
> to be selected).
>

   Please fixed as suggested by Dave and send the patch. I'll update the RM

>
> Selecting a past expiry date is a perfectly valid way to create an account
> that is effectively locked, for example, to allow pre-creation of roles for
> staff that are yet to join.
>
> PostgreSQL doesn't prevent this - why should we?
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EDB: http://www.enterprisedb.com
>
>

-- 
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Principal Software Architect*
*EDB Postgres <http://edbpostgres.com>*

*Mobile: +91 976-788-8246*


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [pgAdmin][RM-6120]: Adding/updating user should not allow to add an older date in account expires.
@ 2021-01-14 12:28  Nikhil Mohite <[email protected]>
  parent: Akshay Joshi <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Nikhil Mohite @ 2021-01-14 12:28 UTC (permalink / raw)
  To: Akshay Joshi <[email protected]>; +Cc: pgadmin-hackers; Dave Page <[email protected]>

Hi Akshay,

Please find the updated patch, updated UI to allow users to select an older
date for the account expires.


Regards,
Nikhil Mohite.

On Thu, Jan 14, 2021 at 2:52 PM Akshay Joshi <[email protected]>
wrote:

> Hi Nikhil
>
> On Thu, Jan 14, 2021 at 2:38 PM Dave Page <[email protected]> wrote:
>
>>
>>
>> On Thu, Jan 14, 2021 at 8:18 AM Akshay Joshi <
>> [email protected]> wrote:
>>
>>> Thanks, patch applied.
>>>
>>> On Thu, Jan 14, 2021 at 11:28 AM Nikhil Mohite <
>>> [email protected]> wrote:
>>>
>>>> Hi Team,
>>>>
>>>> Please find the attached patch for RM-6120
>>>> <https://redmine.postgresql.org/issues/6120;: Adding/updating user
>>>> should not allow to add an older date in account expires.
>>>> Added UI validation if a user enters the account expiration date
>>>> manually.
>>>>
>>>
>> I think this needs to be reverted (and the UI fixed to allow an older
>> date to be selected).
>>
>
>    Please fixed as suggested by Dave and send the patch. I'll update the
> RM
>
>>
>> Selecting a past expiry date is a perfectly valid way to create an
>> account that is effectively locked, for example, to allow pre-creation of
>> roles for staff that are yet to join.
>>
>> PostgreSQL doesn't prevent this - why should we?
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EDB: http://www.enterprisedb.com
>>
>>
>
> --
> *Thanks & Regards*
> *Akshay Joshi*
> *pgAdmin Hacker | Principal Software Architect*
> *EDB Postgres <http://edbpostgres.com>*
>
> *Mobile: +91 976-788-8246*
>


Attachments:

  [application/octet-stream] RM_6120_v2.patch (2.0K, 3-RM_6120_v2.patch)
  download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/roles/static/js/role.js b/web/pgadmin/browser/server_groups/servers/roles/static/js/role.js
index 68909fd8..6c382854 100644
--- a/web/pgadmin/browser/server_groups/servers/roles/static/js/role.js
+++ b/web/pgadmin/browser/server_groups/servers/roles/static/js/role.js
@@ -416,6 +416,7 @@ define('pgadmin.node.role', [
           deps: ['rolcanlogin'],
           placeholder: gettext('No Expiry'),
           helpMessage: gettext('Please note that if you leave this field blank, then password will never expire.'),
+          setMinDate: false,
         },{
           id: 'rolconnlimit',  type: 'int', group: gettext('Definition'),
           label: gettext('Connection limit'), cell: 'integer', min : -1,
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index 24295c74..3686ffe5 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -2820,6 +2820,7 @@ define([
         placeholder: 'YYYY-MM-DD HH:mm:ss Z',
         extraClasses: [],
         helpMessage: null,
+        setMinDate: true,
       },
       events: {
         'blur input': 'onChange',
@@ -3008,6 +3009,18 @@ define([
             data.value = null;
           }
 
+          var dateSettings = {};
+          if (!data.setMinDate) {
+            dateSettings = {
+              'date': data.value,
+            };
+          } else {
+            dateSettings = {
+              'date': data.value,
+              'minDate': data.value,
+            };
+          }
+
           this.$el.find('input').first().datetimepicker(
             _.extend({
               keyBinds: {
@@ -3044,10 +3057,7 @@ define([
                   }
                 },
               },
-            }, this.defaults.options, this.field.get('options'), {
-              'date': data.value,
-              'minDate': data.value,
-            })
+            }, this.defaults.options, this.field.get('options'), dateSettings)
           );
         }
         this.updateInvalid();


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [pgAdmin][RM-6120]: Adding/updating user should not allow to add an older date in account expires.
@ 2021-01-15 06:08  Akshay Joshi <[email protected]>
  parent: Nikhil Mohite <[email protected]>
  0 siblings, 0 replies; 6+ messages in thread

From: Akshay Joshi @ 2021-01-15 06:08 UTC (permalink / raw)
  To: Nikhil Mohite <[email protected]>; +Cc: pgadmin-hackers; Dave Page <[email protected]>

Thanks, patch applied.

On Thu, Jan 14, 2021 at 5:58 PM Nikhil Mohite <
[email protected]> wrote:

> Hi Akshay,
>
> Please find the updated patch, updated UI to allow users to select an
> older date for the account expires.
>
>
> Regards,
> Nikhil Mohite.
>
> On Thu, Jan 14, 2021 at 2:52 PM Akshay Joshi <
> [email protected]> wrote:
>
>> Hi Nikhil
>>
>> On Thu, Jan 14, 2021 at 2:38 PM Dave Page <[email protected]> wrote:
>>
>>>
>>>
>>> On Thu, Jan 14, 2021 at 8:18 AM Akshay Joshi <
>>> [email protected]> wrote:
>>>
>>>> Thanks, patch applied.
>>>>
>>>> On Thu, Jan 14, 2021 at 11:28 AM Nikhil Mohite <
>>>> [email protected]> wrote:
>>>>
>>>>> Hi Team,
>>>>>
>>>>> Please find the attached patch for RM-6120
>>>>> <https://redmine.postgresql.org/issues/6120;: Adding/updating user
>>>>> should not allow to add an older date in account expires.
>>>>> Added UI validation if a user enters the account expiration date
>>>>> manually.
>>>>>
>>>>
>>> I think this needs to be reverted (and the UI fixed to allow an older
>>> date to be selected).
>>>
>>
>>    Please fixed as suggested by Dave and send the patch. I'll update the
>> RM
>>
>>>
>>> Selecting a past expiry date is a perfectly valid way to create an
>>> account that is effectively locked, for example, to allow pre-creation of
>>> roles for staff that are yet to join.
>>>
>>> PostgreSQL doesn't prevent this - why should we?
>>>
>>> --
>>> Dave Page
>>> Blog: http://pgsnake.blogspot.com
>>> Twitter: @pgsnake
>>>
>>> EDB: http://www.enterprisedb.com
>>>
>>>
>>
>> --
>> *Thanks & Regards*
>> *Akshay Joshi*
>> *pgAdmin Hacker | Principal Software Architect*
>> *EDB Postgres <http://edbpostgres.com>*
>>
>> *Mobile: +91 976-788-8246*
>>
>

-- 
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Principal Software Architect*
*EDB Postgres <http://edbpostgres.com>*

*Mobile: +91 976-788-8246*


^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2021-01-15 06:08 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-01-14 05:58 [pgAdmin][RM-6120]: Adding/updating user should not allow to add an older date in account expires. Nikhil Mohite <[email protected]>
2021-01-14 08:17 ` Akshay Joshi <[email protected]>
2021-01-14 09:08   ` Dave Page <[email protected]>
2021-01-14 09:22     ` Akshay Joshi <[email protected]>
2021-01-14 12:28       ` Nikhil Mohite <[email protected]>
2021-01-15 06:08         ` Akshay Joshi <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox