Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session status #188

Open
wil-gerard opened this issue May 23, 2022 · 0 comments · May be fixed by #190
Open

Session status #188

wil-gerard opened this issue May 23, 2022 · 0 comments · May be fixed by #190
Assignees
Labels
feat New feature or request

Comments

@wil-gerard
Copy link
Owner

wil-gerard commented May 23, 2022

Detailed Description

The UserContext Hook currently sends an api endpoint request to /api/user/getuser when the navbar component mounts. This action produces an error in the console anytime a user is not logged in.

@timjacksonm #149

We currently have no way of fetching a user's session status, without also fetching their data.

Context

The current UserContext has a useEffect that attempts to fetch a user's data on initial load. The request passes through authentication middleware, and if unauthenticated, a 401 error is returned that prints to the client-side console. Creating a feature to check a user's authentication status before fetching user data would solve this issue.

Possible Implementation

  • Create an API endpoint checking the request's session state
    • If the user is authenticated:
      Respond { "session" : true }
      Else:
      Respond { "session" : false }
  • Add to UserContext hook
    • An authState passed to the children
    • A useEffect that queries the new session state endpoint
    • If the user is authenticated:
      authState = true && set localStorage item { "session" : true }
      Else:
      authState = false
@wil-gerard wil-gerard added the feat New feature or request label May 23, 2022
@wil-gerard wil-gerard self-assigned this May 23, 2022
@github-actions github-actions bot added the triage Do not begin working on this issue until triaged by the team label May 23, 2022
@wil-gerard wil-gerard removed the triage Do not begin working on this issue until triaged by the team label May 23, 2022
@wil-gerard wil-gerard changed the title authContext Session status May 30, 2022
@wil-gerard wil-gerard linked a pull request May 30, 2022 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant