UI: Added validation scope
This commit is contained in:
parent
220c5f6275
commit
e113daa085
@ -316,6 +316,10 @@
|
|||||||
{{ 'admin.oauth2.scope-required' | translate }}
|
{{ 'admin.oauth2.scope-required' | translate }}
|
||||||
</mat-error>
|
</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
<tb-error style="display: block; margin-top: -24px;"
|
||||||
|
[error]="registration.get('scope').hasError('required')
|
||||||
|
? ('admin.oauth2.scope-required' | translate) : ''">
|
||||||
|
</tb-error>
|
||||||
|
|
||||||
</mat-tab>
|
</mat-tab>
|
||||||
<mat-tab label="{{ 'admin.oauth2.mapper' | translate }}">
|
<mat-tab label="{{ 'admin.oauth2.mapper' | translate }}">
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
///
|
///
|
||||||
|
|
||||||
import { Component, Inject, OnDestroy, OnInit } from '@angular/core';
|
import { Component, Inject, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { AbstractControl, FormArray, FormBuilder, FormGroup, Validators } from '@angular/forms';
|
import { AbstractControl, FormArray, FormBuilder, FormGroup, ValidationErrors, Validators } from '@angular/forms';
|
||||||
import {
|
import {
|
||||||
ClientAuthenticationMethod,
|
ClientAuthenticationMethod,
|
||||||
ClientRegistration,
|
ClientRegistration,
|
||||||
@ -266,7 +266,7 @@ export class OAuth2SettingsComponent extends PageComponent implements OnInit, Ha
|
|||||||
authorizationUri: [clientRegistration?.authorizationUri ? clientRegistration.authorizationUri : '',
|
authorizationUri: [clientRegistration?.authorizationUri ? clientRegistration.authorizationUri : '',
|
||||||
[Validators.required,
|
[Validators.required,
|
||||||
Validators.pattern(this.URL_REGEXP)]],
|
Validators.pattern(this.URL_REGEXP)]],
|
||||||
scope: this.fb.array(clientRegistration?.scope ? clientRegistration.scope : [], Validators.required),
|
scope: this.fb.array(clientRegistration?.scope ? clientRegistration.scope : [], this.validateScope),
|
||||||
jwkSetUri: [clientRegistration?.jwkSetUri ? clientRegistration.jwkSetUri : '', Validators.pattern(this.URL_REGEXP)],
|
jwkSetUri: [clientRegistration?.jwkSetUri ? clientRegistration.jwkSetUri : '', Validators.pattern(this.URL_REGEXP)],
|
||||||
userInfoUri: [clientRegistration?.userInfoUri ? clientRegistration.userInfoUri : '',
|
userInfoUri: [clientRegistration?.userInfoUri ? clientRegistration.userInfoUri : '',
|
||||||
[Validators.required,
|
[Validators.required,
|
||||||
@ -307,6 +307,16 @@ export class OAuth2SettingsComponent extends PageComponent implements OnInit, Ha
|
|||||||
return clientRegistrationFormGroup;
|
return clientRegistrationFormGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private validateScope (control: AbstractControl): ValidationErrors | null {
|
||||||
|
const scope: string[] = control.value;
|
||||||
|
if (!scope || !scope.length) {
|
||||||
|
return {
|
||||||
|
required: true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private setProviderDefaultValue(provider: string, clientRegistration: FormGroup) {
|
private setProviderDefaultValue(provider: string, clientRegistration: FormGroup) {
|
||||||
if (provider === 'Custom') {
|
if (provider === 'Custom') {
|
||||||
clientRegistration.reset(this.defaultProvider, {emitEvent: false});
|
clientRegistration.reset(this.defaultProvider, {emitEvent: false});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user