I am storing a token in localStorage after authentication, but i need to delete it and redirect to some router each time i do a refresh.
I have no ideea how to do it in angular. I am using a very hacky way using plain js.
window.addEventListener('load', function (e) {
if (window.sessionStorage !== null && (window.location.href.indexOf('/signin') === -1 && window.location.href.indexOf('confirm-user') === -1)) {
window.sessionStorage.clear();
window.location.href = '/signin';
}
});
I was thinking of adding an authentication guard, but i'm sure there should be a more angular way of doing this.