Ensure that the account expiration date for role/user can’t be older than the current date. Fixes #6120

This commit is contained in:
Nikhil Mohite
2021-01-14 12:09:03 +05:30
committed by Akshay Joshi
parent 0bd77937de
commit 9a47e574e3
2 changed files with 23 additions and 0 deletions

View File

@@ -562,6 +562,28 @@ define('pgadmin.node.role', [
}
}
// Check Account expiration date should not be older than 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 cant be older than the current date');
errmsg = gettext('Account expiration date cant be older than the current date');
}
this.errorModel.clear().set(err);
if (_.size(err)) {