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)) {