-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Labels
featNew feature or requestNew feature or request
Description
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.
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 }
- If the user is authenticated:
- 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
Metadata
Metadata
Assignees
Labels
featNew feature or requestNew feature or request