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

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

[EDELIVERY-140001] allow to create access tokens which are not yet valid

parent f829a1a3
No related tags found
No related merge requests found
Pipeline #216481 failed
......@@ -74,7 +74,7 @@
[for]="picker"></mat-datepicker-toggle>
<mat-date-range-picker #picker></mat-date-range-picker>
<smp-field-error
*ngIf="credentialForm.controls.activeFrom.hasError('matStartDateInvalid') || credentialForm.controls.activeFrom.hasError('required')">{{ "access.token.panel.error.invalid.start.date" | translate }}
*ngIf="credentialForm.controls.activeFrom.hasError('required')">{{ "access.token.panel.error.invalid.start.date" | translate }}
</smp-field-error>
<smp-field-error
*ngIf="credentialForm.controls.expireOn.hasError('matEndDateInvalid') || credentialForm.controls.expireOn.hasError('required')">{{ "access.token.panel.error.invalid.end.date" | translate }}
......
......@@ -10,19 +10,6 @@ import {BeforeLeaveGuard} from "../../../window/sidenav/navigation-on-leave-guar
import {GlobalLookups} from "../../../common/global-lookups";
export function notAfterCurrentDateValidator(): ValidatorFn {
return (control: AbstractControl): { [key: string]: any } | null => {
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;
};
}
export function notBeforeCurrentDateValidator(): ValidatorFn {
return (control: AbstractControl): { [key: string]: any } | null => {
......@@ -62,7 +49,7 @@ export class AccessTokenPanelComponent implements BeforeLeaveGuard {
'name': new FormControl({value: '', disabled: true}),
'active': new FormControl({value: '', disabled: false}),
'description': new FormControl({value: '', disabled: false}),
'activeFrom': new FormControl({value: '', disabled: false}, [notAfterCurrentDateValidator()]),
'activeFrom': new FormControl({value: '', disabled: false} ),
'expireOn': new FormControl({value: '', disabled: false}, [notBeforeCurrentDateValidator()])
});
......
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