From dfecca309a5812ec656ec9c7e59895563fe46fcf Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Fri, 14 Aug 2020 14:32:57 +0300 Subject: [PATCH] fix: get core options from the config state in auth-flow.strategy --- .../core/src/lib/strategies/auth-flow.strategy.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts b/npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts index 0e86deda69..9ee2279ec7 100644 --- a/npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts +++ b/npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts @@ -1,13 +1,13 @@ import { Injector } from '@angular/core'; +import { Router } from '@angular/router'; import { Store } from '@ngxs/store'; 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 { RestService } from '../services/rest.service'; import { switchMap } from 'rxjs/operators'; 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 { abstract readonly isInternalAuth: boolean; @@ -26,8 +26,8 @@ export abstract class AuthFlowStrategy { constructor(protected injector: Injector) { this.oAuthService = injector.get(OAuthService); - this.oAuthConfig = injector.get(CORE_OPTIONS).environment.oAuthConfig; this.store = injector.get(Store); + this.oAuthConfig = this.store.selectSnapshot(ConfigState.getDeep('environment.oAuthConfig')); } async init(): Promise { @@ -76,10 +76,9 @@ export class AuthPasswordFlowStrategy extends AuthFlowStrategy { } logout() { - const store = this.injector.get(Store); 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 .request( { @@ -92,7 +91,7 @@ export class AuthPasswordFlowStrategy extends AuthFlowStrategy { .pipe( switchMap(() => { this.oAuthService.logOut(); - return store.dispatch(new GetAppConfiguration()); + return this.store.dispatch(new GetAppConfiguration()); }), ); }