I've gotta be missing something obvious, but I can't figure it out and it's driving me crazy. I'm using angular and I have a factory 'Auth' which has this function in the return { } of 'Auth' (forced to return false for emphasis):
isAuthenticated: function() {
var storedJwt = $window.sessionStorage.authToken;
console.log('stored JWT: '+storedJwt);
if(storedJwt){
var storedPayload = jwtHelper.decodeToken(storedJwt);
console.log('payload: '+JSON.stringify(storedPayload));
if(jwtHelper.isTokenExpired(storedJwt)){
console.log('is expired expired: '+jwtHelper.getTokenExpirationDate(storedJwt));
delete $window.sessionStorage.authToken;
} else {
console.log('is not expired expires: '+jwtHelper.getTokenExpirationDate(storedJwt));
}
}
return false;
//LocalService.get('authToken');
},
Then in a controller I'm doing this:
$scope.isLoggedIn = function(){
console.log('chk:'+Auth.isAuthenticated);
return Auth.isAuthenticated;
};
the console.log though is showing: http://grab.by/GZSw
And so always returns true. Why can't I get it to be false? I think this is probably very basic js issue, but I don't get it.