I'm trying to check if an user is authenticated, and I'm using a method that returns an observable of either true or false if the user is authenticated or not. What I'm trying to do is the wait until authorized has a value, then check if it's true or false in the callback function and depending on it's value perform an action. So basically I don't want my filter function to check if the value is true or false, but to check if there is a value before continuing with the code inside the subscription callback.
This is my function:
this.oidcSecurityService.getIsAuthorized().pipe(filter(authorized => authorized !== undefined)).subscribe(authorized => {
console.log(authorized);
this.isAuthorized = authorized;
if (!authorized) {
debugger
this.login()
}
else {
debugger
this.getBoSpar()
}
});
What am I doing wrong, and how can I make the filter function check if authorized is fetched, and not if it's either true or false? I'm not getting any errors, it's just that authorized is always evaluated to false, even though I know that the user is authenticated (I've separating the logic to happen on click events, and that works).
getIsAuthorized? - Vlad274