Browse Source

fix: get core options from the config state in auth-flow.strategy

pull/5060/head
mehmet-erim 6 years ago
parent
commit
dfecca309a
  1. 15
      npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts

15
npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts

@ -1,13 +1,13 @@
import { Injector } from '@angular/core'; import { Injector } from '@angular/core';
import { Router } from '@angular/router';
import { Store } from '@ngxs/store'; import { Store } from '@ngxs/store';
import { AuthConfig, OAuthService } from 'angular-oauth2-oidc'; import { AuthConfig, OAuthService } from 'angular-oauth2-oidc';
import { ConfigState } from '../states/config.state';
import { CORE_OPTIONS } from '../tokens/options.token';
import { Router } from '@angular/router';
import { Observable, of } from 'rxjs'; import { Observable, of } from 'rxjs';
import { RestService } from '../services/rest.service';
import { switchMap } from 'rxjs/operators'; import { switchMap } from 'rxjs/operators';
import { GetAppConfiguration } from '../actions/config.actions'; import { GetAppConfiguration } from '../actions/config.actions';
import { RestOccurError } from '../actions/rest.actions';
import { RestService } from '../services/rest.service';
import { ConfigState } from '../states/config.state';
export abstract class AuthFlowStrategy { export abstract class AuthFlowStrategy {
abstract readonly isInternalAuth: boolean; abstract readonly isInternalAuth: boolean;
@ -26,8 +26,8 @@ export abstract class AuthFlowStrategy {
constructor(protected injector: Injector) { constructor(protected injector: Injector) {
this.oAuthService = injector.get(OAuthService); this.oAuthService = injector.get(OAuthService);
this.oAuthConfig = injector.get(CORE_OPTIONS).environment.oAuthConfig;
this.store = injector.get(Store); this.store = injector.get(Store);
this.oAuthConfig = this.store.selectSnapshot(ConfigState.getDeep('environment.oAuthConfig'));
} }
async init(): Promise<any> { async init(): Promise<any> {
@ -76,10 +76,9 @@ export class AuthPasswordFlowStrategy extends AuthFlowStrategy {
} }
logout() { logout() {
const store = this.injector.get(Store);
const rest = this.injector.get(RestService); const rest = this.injector.get(RestService);
const issuer = store.selectSnapshot(ConfigState.getDeep('environment.oAuthConfig.issuer')); const issuer = this.store.selectSnapshot(ConfigState.getDeep('environment.oAuthConfig.issuer'));
return rest return rest
.request( .request(
{ {
@ -92,7 +91,7 @@ export class AuthPasswordFlowStrategy extends AuthFlowStrategy {
.pipe( .pipe(
switchMap(() => { switchMap(() => {
this.oAuthService.logOut(); this.oAuthService.logOut();
return store.dispatch(new GetAppConfiguration()); return this.store.dispatch(new GetAppConfiguration());
}), }),
); );
} }

Loading…
Cancel
Save