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 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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue