promise from oidc-client in angular 10 constructor is taking too long to resolve, the isLoggedIn function is being called before the constructor places de value in the user variable.
this is my code:
import { UserManager, UserManagerSettings, User } from 'oidc-client';
export class AuthService {
private user: User = null;
private manager = new UserManager(getClientSettings());
privatecachedRequests: Array<HttpRequest<any>> = [];
constructor() {
this.manager.getUser().then(user => {
this.user = user;
});
}
isLoggedIn(): boolean {
return this.user != null && !this.user.expired; <= this.user is null because the constructor did not finished the async part
}
this code was working in angular 8
when I called getUser() function inside my isLoggedIn method, it worked, but i would like to use this from the constructor