From ad2cb7e450660da0bf2fe47c9c36a93b2c640a32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20S=C3=A4ume?= Date: Wed, 8 Jan 2025 14:44:29 +0100 Subject: [PATCH] Fix writing token to API client --- src/app/core/auth/auth.service.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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(() => { }); } }