Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 2e38bcfa authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

Pull request #145: [EDELIVERY-13979] allow to choose same day for expiration

Merge in EDELIVERY/smp from bugfix/EDELIVERY-13979-access-tokens-token-should-be-valid-including-today to development

* commit '2a732ba2':
  [EDELIVERY-13979] allow to choose same day for expiration
parents ae96f195 2a732ba2
No related branches found
No related tags found
No related merge requests found
......@@ -205,7 +205,23 @@ export class CredentialDialogComponent {
}
if (this.isCertificateType) {
credential.certificate = this.certificateData;
} else {
let dateFrom = this.credentialForm.controls['activeFrom'].value;
if (dateFrom) {
// make date mutable and the modification
dateFrom = new Date(dateFrom);
dateFrom.setHours(0, 0, 0, 0);
}
credential.activeFrom = dateFrom
let dateTo = this.credentialForm.controls['expireOn'].value;
if (dateTo) {
// make date mutable and the modification
dateTo = new Date(dateTo);
dateTo.setHours(23, 59, 59, 999);
}
credential.expireOn = dateTo
}
return credential;
}
......
......@@ -12,7 +12,12 @@ import {GlobalLookups} from "../../../common/global-lookups";
export function notAfterCurrentDateValidator(): ValidatorFn {
return (control: AbstractControl): { [key: string]: any } | null => {
const date = control.value;
let date = control.value;
if (date) {
// make date mutable and the modification
date = new Date(date);
date.setHours(0, 0, 0, 0);
}
const forbidden = date && date > Date.now();
return forbidden ? { 'matStartDateInvalid': { value: control.value } } : null;
......@@ -21,7 +26,12 @@ export function notAfterCurrentDateValidator(): ValidatorFn {
export function notBeforeCurrentDateValidator(): ValidatorFn {
return (control: AbstractControl): { [key: string]: any } | null => {
const date = control.value;
let date = control.value;
if (date) {
// make date mutable and the modification
date = new Date(date);
date.setHours(23, 59, 59, 999);
}
const forbidden = date && date < Date.now();
return forbidden ? { 'matEndDateInvalid': { value: control.value } } : null;
};
......@@ -101,7 +111,7 @@ export class AccessTokenPanelComponent implements BeforeLeaveGuard {
if (dateTo) {
// make date mutable and the modification
dateTo = new Date(dateTo);
dateTo.setHours(0, 0, 0, 0);
dateTo.setHours(23, 59, 59, 999);
}
this._credential.expireOn = dateTo
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment