You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 }
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
The text was updated successfully, but these errors were encountered:
Detailed Description
@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
Respond { "session" : true }
Else:
Respond { "session" : false }
authState = true && set localStorage item { "session" : true }
Else:
authState = false
The text was updated successfully, but these errors were encountered: