You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: redirect users to /login if their oauth token is invalid (#19429)
[As mentioned in the
issue](#12056 (comment))
the problem here is the fact this endpoint is returning a 401 instead of
a 200 in this specific case.
Since we actually have enough information before performing this
mutation to know that it'll fail in the case of a bad auth token we'd
ideally re-work the code not to call the mutation on logout and just
perform the local clean up. Unfortunately it seems like the interactions
that this mutation is having with React Query at large is necessary for
our code to work as intended and thus it's not currently possible to
move the local clean up (the code inside of the `onSuccess`) outside of
the mutation. Shout out to @Parkreiner for helping me confirm this.
So until we can re-work the `AuthProvider` to be less brittle this PR
changes `onSuccess` to `onSettled` so that while the mutation still
fails with a 401, the local clean up still runs.
Closes#12056
// We're doing this cleanup in `onSettled` instead of `onSuccess` because in the case where an oAuth refresh token has expired this endpoint will return a 401 instead of 200.
200
+
onSettled: (_,error)=>{
201
+
if(error){
202
+
console.error(error);
203
+
}
204
+
199
205
/**
200
206
* 2024-05-02 - If we persist any form of user data after the user logs
201
207
* out, that will continue to seed the React Query cache, creating
0 commit comments