Move local logout cleanup outside of the logout mutation
- Dominant language
- No language data
- Stars
- 3
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
As described in [this PR](https://github.com/coder/coder/pull/19429) our current `AuthProvider` is reliant on some non-obvious behaviors of React Query in order to work. This has manifested in the inability to move local logout clean up code outside of a the logout mutation.
After taking a look at `AuthProvider` for quite a lot of time I think the best solution here would be to refactor the code so that it's easier to reason about all of the different possible authentication states, and how to transition between each one. For example we currently have separate states for `isSignedOut`, `isSigningOut`, `isSignedIn`, and `isSigningIn`. All of which are independently calculated and not always related in obvious ways.
A better solution may be to have a single source of truth in the form of something like a tagged union:
```ts
type AuthState =
| { state: "signed-in"; user: User }
| { state: "signing-in" }
| { state: "signed-out" }
| { state: "signing-out" };
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.