Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

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

Pull request #169: [EDELIVERY-140001] allow to create access tokens which are not yet valid

Merge in EDELIVERY/smp from bugfix/EDELIVERY-14001-access-token-page-setting-a-start-date-for-an-access-token-triggers-invalid to development

* commit '1cfe3431':
  [EDELIVERY-140001] allow to create access tokens which are not yet valid
parents abc9bf3b 1cfe3431
No related branches found
No related tags found
No related merge requests found
......@@ -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