0

I am developing SPA applications using ReactJS and the react-oidc-context library. All of these SPAs are OIDC-protected Wizards that the user closes/leaves once the wizard is complete.

When the user closed/leaves the wizard, I want to revoke the access tokens they were issued when they initially launched the wizard.

Putting a 'Close' button that revokes the token when the user completes the wizard is easy enough. However, I am stuck on detecting when the user attempts to close/cancel the wizard prematurely. For example, the user starts the wizard and then navigates away to another site. When that occurs, I want to revoke the access token.

How can I detect when a user tries to close/navigate away from a wizard?

user1913559
  • 301
  • 1
  • 13

1 Answers1

0

use the cleanup function in react useEffect

useEffect(() => {
  
  return () => {
    // executed when a component gets unmounted, i.e. the user left the wizard
    dispatch(removeToken()); // if you are using redux

  };
}, []);
Kadir Damene
  • 358
  • 1
  • 3
  • 10