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
When users are logged in, they should not be able to visit certain pages.
currenlty the redirect happens within each private page. For example, HomePage and Profile component use a hook to check if the user is logged in, and redirects them if not.
We want to make a component that can be used across all private routes, without making the actual page component worry about this
How?
Create a PrivateRoute component.
It will use userContext to pull user information. If user does not exist, redirect user to the login page. If user exists, allow the page to be displayed
there are several ways to build this. You can look at this example to get an idea
Use this PrivateRoute on all pages in the Routes file that only logged in users should be able to visit
remove the previous logic in these components that used a hook to redirect users
The text was updated successfully, but these errors were encountered:
Hey @ramya202000,
Thanks for your interest! This issue is already in a PR and being reviewed.
Feel free to check out other issues or join our Discord to chat and get updates.
Why?
How?
PrivateRoute
component.PrivateRoute
on all pages in theRoutes
file that only logged in users should be able to visitThe text was updated successfully, but these errors were encountered: