Browse Source

Refactoring

pull/3557/head
Vladyslav_Prykhodko 6 years ago
parent
commit
4c07e72117
  1. 4
      ui-ngx/src/app/core/guards/redirect-guard-settings.service.ts
  2. 4
      ui-ngx/src/app/modules/home/pages/admin/admin-routing.module.ts
  3. 16
      ui-ngx/src/app/modules/home/pages/admin/oauth2-settings.component.ts

4
ui-ngx/src/app/core/guards/redirect.guard.ts → ui-ngx/src/app/core/guards/redirect-guard-settings.service.ts

@ -26,7 +26,7 @@ import { Authority } from '@shared/models/authority.enum';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
export class RedirectGuard implements CanActivate { export class RedirectGuardSettings implements CanActivate {
constructor(private store: Store<AppState>, constructor(private store: Store<AppState>,
private router: Router) { } private router: Router) { }
@ -41,7 +41,7 @@ export class RedirectGuard implements CanActivate {
); );
if (auth?.userDetails?.authority === Authority.TENANT_ADMIN) { if (auth?.userDetails?.authority === Authority.TENANT_ADMIN) {
this.router.navigateByUrl('/settings/oauth2-settings'); this.router.navigateByUrl('/settings/oauth2');
return false; return false;
} }
this.router.navigateByUrl('/settings/general'); this.router.navigateByUrl('/settings/general');

4
ui-ngx/src/app/modules/home/pages/admin/admin-routing.module.ts

@ -23,7 +23,7 @@ import { Authority } from '@shared/models/authority.enum';
import { GeneralSettingsComponent } from '@modules/home/pages/admin/general-settings.component'; import { GeneralSettingsComponent } from '@modules/home/pages/admin/general-settings.component';
import { SecuritySettingsComponent } from '@modules/home/pages/admin/security-settings.component'; import { SecuritySettingsComponent } from '@modules/home/pages/admin/security-settings.component';
import { OAuth2SettingsComponent } from '@home/pages/admin/oauth2-settings.component'; import { OAuth2SettingsComponent } from '@home/pages/admin/oauth2-settings.component';
import { RedirectGuard } from '@core/guards/redirect.guard'; import { RedirectGuardSettings } from '../../../../core/guards/redirect-guard-settings.service';
const routes: Routes = [ const routes: Routes = [
{ {
@ -38,7 +38,7 @@ const routes: Routes = [
children: [ children: [
{ {
path: '', path: '',
canActivate: [RedirectGuard], canActivate: [RedirectGuardSettings],
pathMatch: 'full' pathMatch: 'full'
}, },
{ {

16
ui-ngx/src/app/modules/home/pages/admin/oauth2-settings.component.ts

@ -57,7 +57,9 @@ export class OAuth2SettingsComponent extends PageComponent implements OnInit, Ha
private subscriptions: Subscription[] = []; private subscriptions: Subscription[] = [];
private templates = new Map<string, ClientProviderTemplated>(); private templates = new Map<string, ClientProviderTemplated>();
private defaultProvider = { private defaultProvider = {
providerName: 'Custom', additionalInfo: {
providerName: 'Custom'
},
clientAuthenticationMethod: 'Post', clientAuthenticationMethod: 'Post',
userNameAttributeName: 'email', userNameAttributeName: 'email',
mapperConfig: { mapperConfig: {
@ -105,7 +107,6 @@ export class OAuth2SettingsComponent extends PageComponent implements OnInit, Ha
this.initTemplates(templates); this.initTemplates(templates);
this.oauth2Settings = oauth2Settings; this.oauth2Settings = oauth2Settings;
this.initOAuth2Settings(this.oauth2Settings); this.initOAuth2Settings(this.oauth2Settings);
// this.oauth2SettingsForm.get('clientDomains').updateValueAndValidity();
} }
); );
} }
@ -300,7 +301,13 @@ export class OAuth2SettingsComponent extends PageComponent implements OnInit, Ha
clientRegistration.get('authorizationUri').disable(); clientRegistration.get('authorizationUri').disable();
clientRegistration.get('jwkSetUri').disable(); clientRegistration.get('jwkSetUri').disable();
clientRegistration.get('userInfoUri').disable(); clientRegistration.get('userInfoUri').disable();
clientRegistration.patchValue(this.templates.get(provider), {emitEvent: false}); clientRegistration.patchValue({
...template, ...{
clientId: '',
clientSecret: '',
id: {id: null, entityType: null}
}
}, {emitEvent: false});
} }
})); }));
@ -477,6 +484,9 @@ export class OAuth2SettingsComponent extends PageComponent implements OnInit, Ha
getHelpLink(controller: AbstractControl): string { getHelpLink(controller: AbstractControl): string {
const provider = controller.get('additionalInfo.providerName').value; const provider = controller.get('additionalInfo.providerName').value;
if (provider === null || provider === 'Custom') {
return '';
}
return this.templates.get(provider).helpLink; return this.templates.get(provider).helpLink;
} }
} }

Loading…
Cancel
Save