supertokens-auth-react icon indicating copy to clipboard operation
supertokens-auth-react copied to clipboard

Have the auth wrapper take care of session expiry as well

Open rishabhpoddar opened this issue 4 years ago • 1 comments

  • We would like it to show a popup in case an API call results in session expiry - so that the user does not have to handle this themselves.
  • The popup will have a message like "Your session has expired, please login again". There will be an "OK" button which if clicked will take the user to the sign in up page.
  • This will require modifications to the supertokens-website and this package. The supertokens-website package will send a signal in case of session expiry and this package will listen for that and display a popup accordingly.
  • As usual, we allow the user to change the message or the entire popup UI. We should also allow them to disable this popup entirely.

rishabhpoddar avatar Mar 07 '21 06:03 rishabhpoddar

Hi! I'd like to work on this issue. Here's how I'm thinking of approaching it:

  • We’re already emitting the relevant event in supertokens-website/fetch.ts.

  • We can listen for that event within the SessionAuth component and trigger a modal on session expiry.

  • There are two potential approaches regarding modal handling: Option 1: If the client passes an onSessionExpired prop to SessionAuth, we assume they’re handling the session expiry themselves and skip showing the default modal. Option 2: Always show a default expiry modal but allow customization via props like showExpiryModal and expiryModalMessage.

  • Regardless of the option, users will still have full control to show their own modal via the onSessionExpired callback if preferred.

Let me know if this direction sounds good, or if you'd like me to make any adjustments before I get started.

zhbdripon avatar May 26 '25 15:05 zhbdripon