feat: validation in routes to redirect to login if user is not auth#183
feat: validation in routes to redirect to login if user is not auth#183jesusbalderramawgu wants to merge 4 commits intoopenedx:mainfrom
Conversation
|
Thanks for the pull request, @jesusbalderramawgu! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. 🔘 Update the status of your PRYour PR is currently marked as a draft. After completing the steps above, update its status by clicking "Ready for Review", or removing "WIP" from the title, as appropriate. Where can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
shell/router/AuthGuard.tsx
Outdated
| return; | ||
| } | ||
|
|
||
| // user already authenticated |
There was a problem hiding this comment.
a bit confusing isn't it?
I mean, you are cheking if it's already authenticated....
arbrandes
left a comment
There was a problem hiding this comment.
Before I dig any deeper: I should have noted before that we already have a component that has the same purpose:
We should either use it as-is if possible, or modify it if not, instead of creating a new one. For instance, one problem I see with it is that it doesn't navigate(), it sets the location manually.
Other changes to the auth infrastructure might be necessary, but this is as good a time to make them as any!
I used the component you mentioned, I found it here |
Description
PR to add validation in the different routes from the projects that consume the frontend-base package
this closes the issue142 and 154
How Has This Been Tested?
In the project that needs to use the mechanism and redirect any unauthenticated user to login page we need to add a flag to any route that required this validation.
requireAuthenticatedUser: true,Example from the learner dashboard

Steps to reproduce
1.- if you open the learner dashboard url without a user logged in, and without the new flag in the router you will see the learner dashboard page in an incorrect state because no user is authenticated.

2.- If you do the same but with the new flag added into the route you will see the correct redirection to the login page.

Note:
This works properly, but I marked this PR as draft because it shows the header and the footer for just a moment ( not sure if that's fine right now and we can tackle that in other PR or if that's a blocker to merge this)

This happens because basically the route controls the main-content but the header and footer are always visible.