Why is the login status null instead of false in this method?
// In the method below, I am trying to return only true or false.
isLoggedIn(): Observable<boolean> {
return this
.loadToken()
.catch(e => {
this.logger.info(e); // This message is logged...
this.token = null;
return Observable.of(false); // I explicitly return false here.
})
.map(_ => this.token && this.token.access_token.length > 0);
This method is called from here
return this.authService.isLoggedIn().map(_ => {
this.logger.info(`authorisation guard :: login status ${_}`);
if (_)
return true;
this.router.navigate(["login"]);
return Observable.of(false);
}).catch(_ => {
this.logger.info(`authorisation guard :: login error ${_}`);
this.router.navigate(["login"]);
return Observable.of(false);
});
The following message gets logged:
2017-09-09T06:55:46Z [INFO] authorisation guard :: login status null
I am expecting:
2017-09-09T06:55:46Z [INFO] authorisation guard :: login status false