- Notifications
You must be signed in to change notification settings - Fork928
Closed
Description
In accordance withhttps://www.notion.so/coderhq/v2-Frontend-State-Management-APPROVED-e5ccb3c6357649f9a9dc1a1b2a1b7a99, we will use a machine to encapsulate API calls about the current user and hold user state.
- replace
UserContext
withuserMachine
- refactor all checks for authentication
- refactor
SignInPage
to useuserMachine
Requirements:
Given a current user created in the database,
- user can log in
- user can log out
- logged in user can view pages that require authentication
- logged in user on /login gets redirected to /projects
- logged out user cannot view pages that require authentication, and is redirected to /login. Upon logging in, the user is returned to the page they were trying to access.
- logged out user can view /login and 404 page
Implementation goals:
- install XState and related packages
- set up dev tools - half done, seeImprove XState dev tool setup #462
- set up typegen - half done, seeDebug and automate XState typegen #456
- replace user Context with user xservice
- use xservice only in glue components
Testing goals:
- Storybook NavbarView
- Storybook SignInForm
- TBD mix of unit, integration, e2e tests to cover auth behavior