I am using ngStorage for storing data in local storage. I am facing this weird issue where, when I am deleting the localstorage from the browser, my website's user doesn't get logged out on url change.
Here's the code that keeps the check whether the localstorage exists or not and then does the appropriate route:
$rootScope.$on('$locationChangeStart', function (event, next, current) {
//it always by passes this
if (!$localStorage.currentUser) {
$location.path('/login');
}
});
Only when I refresh the page, it automatically routes to the login page, or else it continues to go on any route in the website and that too without having the localstorage value.
Why's this happening ? please help me
Try this