where is the best place to do authentication check...
# compose
u
where is the best place to do authentication checks and redirect to login if a user's session has expired ? The intuition is to do the checks in every screen but that seems like a lot of repetitive code,
s
How often does a user's session expire? Are you doing something extremely sensitive where they need to frequently re-enter their credentials? Normally, you should use a refresh token to not bother your user. In that case, I would make the check when you try to access whatever resource they need to be authenticated for, because you're going to need to handle that case regardless. You might also want to be proactive and monitor the access token at the top level of your app and refresh it on expiry or redirect the user to re-login when the refresh fails. One issue here is that the network may be flaky and the refresh could be retried. You'll need to decide what to do in that situation.
z
This isn’t really a compose question but an architecture/design one