diff --git a/src/app/core/auth/auth.service.ts b/src/app/core/auth/auth.service.ts index fdef309..f543630 100644 --- a/src/app/core/auth/auth.service.ts +++ b/src/app/core/auth/auth.service.ts @@ -1,7 +1,9 @@ -import {Injectable} from '@angular/core'; +import { Injectable } from '@angular/core'; import UserData from '@core/auth/UserData'; -import {OidcSecurityService} from 'angular-auth-oidc-client'; -import {Observable} from 'rxjs'; +import { OidcSecurityService } from 'angular-auth-oidc-client'; +import { Observable } from 'rxjs'; + +import { OpenAPI } from '../ems'; @Injectable({ providedIn: 'root' @@ -11,13 +13,14 @@ export class AuthService { constructor(private readonly oidcSecurityService: OidcSecurityService) { this.$user = new Observable((publish) => { - this.oidcSecurityService.checkAuth().subscribe(({isAuthenticated, userData}) => { + this.oidcSecurityService.checkAuth().subscribe(({ isAuthenticated, userData }) => { publish.next(isAuthenticated ? { username: userData.preferred_username, verified: userData.email_verified } : undefined); }); }); + this.oidcSecurityService.getAccessToken().subscribe(token => OpenAPI.TOKEN = token); } @@ -26,7 +29,7 @@ export class AuthService { } logout() { - this.oidcSecurityService.logoff(); + this.oidcSecurityService.logoff().subscribe(() => { }); } }