diff --git a/smp-angular/src/app/common/dialogs/credential-dialog/credential-dialog.component.ts b/smp-angular/src/app/common/dialogs/credential-dialog/credential-dialog.component.ts index 1deb1ae92a62e22ec0bc58de684096588c0c69d3..73f7dfc18d6efb34f85f54f136c0999442f99eb4 100644 --- a/smp-angular/src/app/common/dialogs/credential-dialog/credential-dialog.component.ts +++ b/smp-angular/src/app/common/dialogs/credential-dialog/credential-dialog.component.ts @@ -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; } diff --git a/smp-angular/src/app/user-settings/user-access-tokens/access-token-panel/access-token-panel.component.ts b/smp-angular/src/app/user-settings/user-access-tokens/access-token-panel/access-token-panel.component.ts index f290f68eabf2061190e857918fcd1d3271cc33e5..285eb0024c1649fd2a03a697165bceda2795a7e9 100644 --- a/smp-angular/src/app/user-settings/user-access-tokens/access-token-panel/access-token-panel.component.ts +++ b/smp-angular/src/app/user-settings/user-access-tokens/access-token-panel/access-token-panel.component.ts @@ -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