Fix writing token to API client
This commit is contained in:
parent
11e417bb07
commit
473100ab0c
1 changed files with 7 additions and 4 deletions
|
@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue