My AngularJs application is designed to navigate to the login page if the user is not logged in and attempts to access a route that requires authentication.
if ($localStorage.globals.access_token) {
$rootScope.globals = $localStorage.globals;
$state.go('app.dashboard-v1');
} else {
$state.go('access.signin)
}
Every time the application loads, this code block is executed. The issue arises when I try to access a route that necessitates a logged-in user. Instead of redirecting to the login page as expected, it first begins the redirection process to the login page (access.signin), but for some reason does not complete it, then proceeds with accessing the specific route (in this case, I attempted to access the app.dashboard-v1 state by its URL) before ultimately completing the redirection to the login page. What am I doing wrong here?