Skip to content

feature(route guarding): incomplete #118

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

Closed
wants to merge 1 commit into from

Conversation

mcspach
Copy link

@mcspach mcspach commented Jun 29, 2021

Approach

Added new file guard.js to define a new component called GuardedRoute, which would check for authentication before rendering the component. Otherwise would redirect to login page.
I wanted to use this component to check if there was an active token, but my approach doesn't seem to be fully working.
'props.auth.token' returns undefined. I have attempted this task multiple times and there always seems to be a slight error. Not familiar enough with React to know the best practices here.

Links

https://www.freecodecamp.org/news/a-complete-beginners-guide-to-react-router-include-router-hooks/#guarding-routes
https://dev.to/karanpratapsingh/private-public-and-restricted-routes-in-react-42ff
https://medium.com/weekly-webtips/protect-your-route-with-protectedroute-and-guards-in-reactjs-2db83ec48860

Doesn't quite solve #21

@mcspach mcspach changed the title feature(route guarding): INCOMPLETE feature(route guarding): incomplete Jun 29, 2021
@mcspach mcspach closed this Jun 29, 2021
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.

1 participant