Skip to content

implement private route component#234

Open
Owobilum wants to merge 2 commits into
lugenx:mainfrom
Owobilum:private-route-component
Open

implement private route component#234
Owobilum wants to merge 2 commits into
lugenx:mainfrom
Owobilum:private-route-component

Conversation

@Owobilum

@Owobilum Owobilum commented Aug 8, 2023

Copy link
Copy Markdown

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

lugenx commented Aug 9, 2023

Copy link
Copy Markdown
Owner

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
Copy Markdown
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

@tsimian tsimian left a comment

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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

@tsimian tsimian left a comment

Copy link
Copy Markdown
Collaborator

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!

setUser(user) // store user in state because user is checked to determine private route access
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

lugenx commented Aug 28, 2023

Copy link
Copy Markdown
Owner

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

@lugenx

lugenx commented Oct 23, 2023

Copy link
Copy Markdown
Owner

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