Send users to log in screen when auth is expired

How do i send the users to log in again when token has expired.

Right now i have it as “An unhandled error occurs”, but thatt doesnt seem to work.

The Auth token is coming from an API

The options for redirecting a user when an auth token expires (assuming that token is saved in your database on the user record, along with its expiration date) are:

  • Page is loaded workflow → only when current user's token expiration < current date / time
  • Do when condition is true workflow → every time → only when current user's token expiration < current date/time

The page is loaded workflow will be less taxing on your app since you won’t have to be constantly looking at that database field and evaluating that condition for the “do when condition is true” workflow. But the downside is it will require your user to refresh the page before they are “kicked out.”

The “do when condition is true” workflow isn’t necessarily problematic on its own, but you should be careful with the number of these workflows you use throughout your app - they can quickly cause the entire app to slow down if you are evaluating too many conditions (particularly conditions that involve searched or filters).


Hey Sam,

So i do store the token within the user database on bubble. I see your reference above with the “page is loaded workflow” but i am having trouble creating it.

Do i have to store an expiration data for each token?

Hey John -

Yes - since your token and expiration date are coming from the API, you’ll want to avoid having to call that API on any sort of regular schedule to continually access that data - instead, you should save it to your database upon successful login, so that you can always know whether the “current user” has a valid or expired token.

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.