Fix writing token to API client
All checks were successful
Quality Check / Linting (push) Successful in 23s
Quality Check / Linting (pull_request) Successful in 22s

This commit is contained in:
Dominik Säume 2025-01-08 14:44:29 +01:00
parent 11e417bb07
commit ad2cb7e450

View file

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