Commit 4c07e721175ed51f86b2aa578dc97ad5db5c201d

Authored by Vladyslav_Prykhodko
1 parent 1f3bae92

Refactoring

ui-ngx/src/app/core/guards/redirect-guard-settings.service.ts renamed from ui-ngx/src/app/core/guards/redirect.guard.ts
... ... @@ -26,7 +26,7 @@ import { Authority } from '@shared/models/authority.enum';
26 26 @Injectable({
27 27 providedIn: 'root'
28 28 })
29   -export class RedirectGuard implements CanActivate {
  29 +export class RedirectGuardSettings implements CanActivate {
30 30 constructor(private store: Store<AppState>,
31 31 private router: Router) { }
32 32
... ... @@ -41,7 +41,7 @@ export class RedirectGuard implements CanActivate {
41 41 );
42 42
43 43 if (auth?.userDetails?.authority === Authority.TENANT_ADMIN) {
44   - this.router.navigateByUrl('/settings/oauth2-settings');
  44 + this.router.navigateByUrl('/settings/oauth2');
45 45 return false;
46 46 }
47 47 this.router.navigateByUrl('/settings/general');
... ...
... ... @@ -23,7 +23,7 @@ import { Authority } from '@shared/models/authority.enum';
23 23 import { GeneralSettingsComponent } from '@modules/home/pages/admin/general-settings.component';
24 24 import { SecuritySettingsComponent } from '@modules/home/pages/admin/security-settings.component';
25 25 import { OAuth2SettingsComponent } from '@home/pages/admin/oauth2-settings.component';
26   -import { RedirectGuard } from '@core/guards/redirect.guard';
  26 +import { RedirectGuardSettings } from '../../../../core/guards/redirect-guard-settings.service';
27 27
28 28 const routes: Routes = [
29 29 {
... ... @@ -38,7 +38,7 @@ const routes: Routes = [
38 38 children: [
39 39 {
40 40 path: '',
41   - canActivate: [RedirectGuard],
  41 + canActivate: [RedirectGuardSettings],
42 42 pathMatch: 'full'
43 43 },
44 44 {
... ...
... ... @@ -57,7 +57,9 @@ export class OAuth2SettingsComponent extends PageComponent implements OnInit, Ha
57 57 private subscriptions: Subscription[] = [];
58 58 private templates = new Map<string, ClientProviderTemplated>();
59 59 private defaultProvider = {
60   - providerName: 'Custom',
  60 + additionalInfo: {
  61 + providerName: 'Custom'
  62 + },
61 63 clientAuthenticationMethod: 'Post',
62 64 userNameAttributeName: 'email',
63 65 mapperConfig: {
... ... @@ -105,7 +107,6 @@ export class OAuth2SettingsComponent extends PageComponent implements OnInit, Ha
105 107 this.initTemplates(templates);
106 108 this.oauth2Settings = oauth2Settings;
107 109 this.initOAuth2Settings(this.oauth2Settings);
108   - // this.oauth2SettingsForm.get('clientDomains').updateValueAndValidity();
109 110 }
110 111 );
111 112 }
... ... @@ -300,7 +301,13 @@ export class OAuth2SettingsComponent extends PageComponent implements OnInit, Ha
300 301 clientRegistration.get('authorizationUri').disable();
301 302 clientRegistration.get('jwkSetUri').disable();
302 303 clientRegistration.get('userInfoUri').disable();
303   - clientRegistration.patchValue(this.templates.get(provider), {emitEvent: false});
  304 + clientRegistration.patchValue({
  305 + ...template, ...{
  306 + clientId: '',
  307 + clientSecret: '',
  308 + id: {id: null, entityType: null}
  309 + }
  310 + }, {emitEvent: false});
304 311 }
305 312 }));
306 313
... ... @@ -477,6 +484,9 @@ export class OAuth2SettingsComponent extends PageComponent implements OnInit, Ha
477 484
478 485 getHelpLink(controller: AbstractControl): string {
479 486 const provider = controller.get('additionalInfo.providerName').value;
  487 + if (provider === null || provider === 'Custom') {
  488 + return '';
  489 + }
480 490 return this.templates.get(provider).helpLink;
481 491 }
482 492 }
... ...