From 014a2fc1670d75a9745d32e89c49a48cca897480 Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Fri, 7 Aug 2020 18:30:54 +0300 Subject: [PATCH] feat: add an if condition to auth service for code flow --- .../packages/core/src/lib/services/auth.service.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/npm/ng-packs/packages/core/src/lib/services/auth.service.ts b/npm/ng-packs/packages/core/src/lib/services/auth.service.ts index 3a343fd2cb..063b1bc74f 100644 --- a/npm/ng-packs/packages/core/src/lib/services/auth.service.ts +++ b/npm/ng-packs/packages/core/src/lib/services/auth.service.ts @@ -3,13 +3,13 @@ import { Inject, Injectable, Optional } from '@angular/core'; import { Navigate } from '@ngxs/router-plugin'; import { Store } from '@ngxs/store'; import { OAuthService } from 'angular-oauth2-oidc'; -import { from, Observable } from 'rxjs'; -import { switchMap, tap, take } from 'rxjs/operators'; +import { from, Observable, of } from 'rxjs'; +import { switchMap, take, tap } from 'rxjs/operators'; import snq from 'snq'; import { GetAppConfiguration } from '../actions/config.actions'; +import { ConfigState } from '../states/config.state'; import { SessionState } from '../states/session.state'; import { RestService } from './rest.service'; -import { ConfigState } from '../states/config.state'; @Injectable({ providedIn: 'root', @@ -48,6 +48,11 @@ export class AuthService { logout(): Observable { const issuer = this.store.selectSnapshot(ConfigState.getDeep('environment.oAuthConfig.issuer')); + if (this.oAuthService.responseType === 'code') { + this.oAuthService.logOut(); + return of(null); + } + return this.rest .request( { @@ -59,7 +64,7 @@ export class AuthService { ) .pipe( switchMap(() => { - this.oAuthService.logOut(true); + this.oAuthService.logOut(); return this.store.dispatch(new GetAppConfiguration()); }), );