Skip to content

Replace User Context with User machine #435

Closed

Description

@presleyp

In accordance with https://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 with userMachine
  • refactor all checks for authentication
  • refactor SignInPage to use userMachine

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:

Testing goals:

  • Storybook NavbarView
  • Storybook SignInForm
  • TBD mix of unit, integration, e2e tests to cover auth behavior

Activity

  1. added this to the V2 Beta milestone on Mar 14, 2022
  2. self-assigned this
    on Mar 14, 2022
  3. greyscaled commented on Mar 14, 2022

    @greyscaled
    Contributor

    @presleyp I'm really excited for this change, I'd love to be pinged on review for when it's ready to help out in testing and to learn about the architecture!

    🙌🏻 🎉

  4. greyscaled commented on Mar 14, 2022

    @greyscaled
    Contributor

    Oh @presleyp is this a duplicate of #434 , or something that Zenhub is doing 😕?

  5. presleyp commented on Mar 14, 2022

    @presleyp
    ContributorAuthor

    Oh it errored the first time I hit create so I guess it created twice!

  6. misskniss commented on Apr 1, 2022

    @misskniss

    🎉

  7. misskniss commented on Apr 1, 2022

    @misskniss

    @presleyp Will you add the points to this that you think it was worth?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

siteArea: frontend dashboard

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions