Browse Source

feat: add an if condition to auth service for code flow

pull/4995/head
mehmet-erim 6 years ago
parent
commit
014a2fc167
  1. 13
      npm/ng-packs/packages/core/src/lib/services/auth.service.ts

13
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 { Navigate } from '@ngxs/router-plugin';
import { Store } from '@ngxs/store'; import { Store } from '@ngxs/store';
import { OAuthService } from 'angular-oauth2-oidc'; import { OAuthService } from 'angular-oauth2-oidc';
import { from, Observable } from 'rxjs'; import { from, Observable, of } from 'rxjs';
import { switchMap, tap, take } from 'rxjs/operators'; import { switchMap, take, tap } from 'rxjs/operators';
import snq from 'snq'; import snq from 'snq';
import { GetAppConfiguration } from '../actions/config.actions'; import { GetAppConfiguration } from '../actions/config.actions';
import { ConfigState } from '../states/config.state';
import { SessionState } from '../states/session.state'; import { SessionState } from '../states/session.state';
import { RestService } from './rest.service'; import { RestService } from './rest.service';
import { ConfigState } from '../states/config.state';
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
@ -48,6 +48,11 @@ export class AuthService {
logout(): Observable<void> { logout(): Observable<void> {
const issuer = this.store.selectSnapshot(ConfigState.getDeep('environment.oAuthConfig.issuer')); const issuer = this.store.selectSnapshot(ConfigState.getDeep('environment.oAuthConfig.issuer'));
if (this.oAuthService.responseType === 'code') {
this.oAuthService.logOut();
return of(null);
}
return this.rest return this.rest
.request( .request(
{ {
@ -59,7 +64,7 @@ export class AuthService {
) )
.pipe( .pipe(
switchMap(() => { switchMap(() => {
this.oAuthService.logOut(true); this.oAuthService.logOut();
return this.store.dispatch(new GetAppConfiguration()); return this.store.dispatch(new GetAppConfiguration());
}), }),
); );

Loading…
Cancel
Save