The problem is we are not waiting for session data to load before using it in other components.
While the session is loading, session data is undefined and status === "loading", show the loading screen
When there's an error retrieving session data the value is null, redirect them to /login
When the user is somehow unauthenticated the status === "unauthenticated", redirect them to /login
Create a utility function that can be used throughout the codebase to check for this. Also, investigate NextAuth's client-side documentation to see elegant ways to do this.
Other Notes
Hamza has partially completed this on the account page in this #155, however it should be tested further and made into a utility
Description
The problem is we are not waiting for session data to load before using it in other components.
undefined
andstatus === "loading"
, show the loading screennull
, redirect them to/login
status === "unauthenticated"
, redirect them to/login
Create a utility function that can be used throughout the codebase to check for this. Also, investigate NextAuth's client-side documentation to see elegant ways to do this.
Other Notes