In a very very worst case, If you see that the API which is used to fetch the permitted features for an authenticated user, responds with empty feature list or simply the call fails, means an authenticated user has no permitted feature for the application (i know it sounds weird, but it can happen in the worst case, suppose your database is crashed or some internal error has occurred on server side), how are you gonna handle this on client side?
If you didn't get the point, here is the flow
(user logs in, after login user should be redirected to my-profile page. but there is a guard against my profile and it has to be resolved with a backend call that responds the permitted feature for the logged in user's role).
- clearing the cookie and redirecting to the login page (logging out actually) with a convenient toast message like "something went wrong, please try later". Because, if the token is stored, then the frontend routing mechanism will fall in an infinite loop. As the current routing request will fail because of empty feature list and it will surely cause the user to stumble upon the login page again, and in login page it will see that there is still stored a token in cookie, thus the user should be proceeded to the next route, and the loop will just continue like this :
login>my-profile my-profile>login.
Instead of logging out, redirecting to a page without a route guard, that contains convenient information about the error so that user doesn't have to repeat the login later. Because if you logout the user and he/she tries to login again, the same scenario might repeat untill there is a fix on server side.
Doing nothing. Let the loop continue till there is a fix. Thus the API will be called INFINITELY!!!!!!!! untill the respective feature is returned for the requested route. It is good when the backend call fails for no good reason and everything becomes okay on next call. But if it persists for a long time, can u see the catastrophe on server side for the continuous client request ???
Please share if you have anything that seems more convenient other than these.