After strungling a long time, i still could not prevent the user from going to login page once they are already logged in
given here my desired state flow:
login → dashboard —> … —> account (sign out) —> login
//in loginViewController:
$location.path(‘/dashboard’).replace();
$state.go(“dashboard”)
//does not work
By pressing the physical back button serveral times, users can go to login page with out signing out from account page. I also don’t want the users to be stuck by redirection. It should remove the login view from the history stack.
That will clear the current view (login) from the history. When the user is on the dashboard, and they hit the back button, the app will close since the dashboard is now the only item in the view history.
Add the same code to your account sign out before the redirect to the login view. This way after the user is signed out, hitting the back button from the log in screen will only close the app.
Hi. I tried with putting the above code before redirecting to dashboard and it is working as expected. But once I am on dashboard, click log out from side menu, and redirect to login view again, the back button does nothing. Could you please suggest how to make the back button work with logging out process? Thanks.