Logic regarding Authentication, Expired or Rejected Token and Logout

All my server api's (custom) return a 401 error with a specific response when the token has expired or is rejected. I'd like to perform a logout at this point. Two questions, one specific and one general. I wrote a custom function to determine if we need to logout or not but not sure how to apply it.

  1. With a backend query, how do I check to determine this case and call logout?

  2. More generically, I know I can create an Action to do this, but don't really want to do it for every single API call. Is there a more programmatic way to achieve this globally across many API calls? What's the best strategy here?

Thanks!

1
2 replies