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

implement private route component #234

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Owobilum
Copy link

@Owobilum Owobilum commented Aug 8, 2023

What does this PR do?

@Owobilum Owobilum requested a review from lugenx as a code owner August 8, 2023 11:33
@lugenx lugenx requested review from rcamach7 and tsimian August 9, 2023 21:15
@lugenx lugenx linked an issue Aug 9, 2023 that may be closed by this pull request
@lugenx
Copy link
Owner

lugenx commented Aug 9, 2023

Hi @Owobilum, this is currently under review. could you please leave a comment under the issue? That way, I can assign it to you. Thanks!

@Owobilum
Copy link
Author

Hi @Owobilum, this is currently under review. could you please leave a comment under the issue? That way, I can assign it to you. Thanks!

Hello @lugenx, it's done

Copy link
Collaborator

@tsimian tsimian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @Owobilum! I noticed though that from the ResponsiveAppBar the user can click 'Home' and be directed to the Homepage still.

@Owobilum
Copy link
Author

Nice work @Owobilum! I noticed though that from the ResponsiveAppBar the user can click 'Home' and be directed to the Homepage still.

Hello @tsimian. Kindly check again

Copy link
Collaborator

@tsimian tsimian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me @lugenx and @rcamach7. Well done @Owobilum!

setLoggedIn(true);
navigate("/");
navigate("/", { state:user }); // store user in route state because "/" route will render with the old user state at this point
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QQ here. If we update the state via our context as we do a few lines up from this, does route "/" render old user state data? I haven't really used this feature from react router dom, but it looks like its a way to carry state across routes. If so our user context is already doing this, correct?


function PrivateRoute({ children }) {
const location = useLocation();
const userInLocation = location.state;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the difference here vs the state we are tracking on userContext?

@rcamach7
Copy link
Collaborator

I just have a few questions, it's looking great though! Coming to think of it, we will need additional protected routes but for users who are already signed in, that can't visit pages such as /login, since they are already logged in. This can be taken care of on a different issue!

@lugenx
Copy link
Owner

lugenx commented Aug 28, 2023

hi @Owobilum , when you get a chance, could you please address @rcamach7 's comments above? thank you.

@lugenx
Copy link
Owner

lugenx commented Oct 23, 2023

Hi @Owobilum , any update?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create Private Route Component
4 participants