Repository navigation
fix(ENG38-1087): redirect to login when the learner has no session - #93
Merged
Merged
Conversation
Set requireAuthenticatedUser so a learner who loads the MFE without a session (no JWT, and /login_refresh returns 401) is sent to LOGIN_URL, which hands off to PingFed SSO and returns them to the course, instead of landing on the generic error page or the access-denied page. Requires the academy-oedx-plugin ibl_tpa fix so that /login_refresh returns 401 for anonymous users instead of redirecting to PingFed.
jsnwesson
approved these changes
Dec 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
When a learner opens the learning MFE without a valid session, they currently see frontend-platform's generic "An unexpected error occurred" page. Depending on the LMS configuration, they may see the "You don't have permission to access this page" page instead. Neither page offers a way to sign in.
This PR sets
requireAuthenticatedUser: trueininitialize(). At startup, frontend-platform'sensureAuthenticatedUser()now redirects a learner with no session toLOGIN_URL, with anextparameter pointing back to the requested page. On our LMS, that login URL hands off to SSO, and the learner comes back to the same unit after signing in. A learner with a valid session sees no change.Dependency: this needs the LMS's
/login_refreshendpoint to return 401 for anonymous users, which is upstream's behavior. frontend-platform only treats a 401 as "not logged in". Our LMS plugin had been redirecting that endpoint to SSO, and the cross-origin redirect failed CORS before the app could act on it. That is fixed in a companion PR to the Academy LMS plugin (academy-oedx-plugin#152). Deploy the plugin fix first. Without it, this change has no effect, and learners keep seeing the generic error page.Known gap:
requireAuthenticatedUseronly runs at startup. If both the session and the JWT expire while a learner is on a page, the next unit navigation shows the unit's error panel. Its "Try again" button reloads the page, which then redirects to login. A route-change session check would remove that step. I tested one, but it's left out of this PR to keep the change small.Tests: no unit test was added. The change is a single
initialize()option and is covered by the manual testing below. The existing suite passes.How to test
With the LMS plugin fix deployed:
/learning/course/<course-id>/<sequence-id>/<unit-id>. You should be redirected to login, and returned to that unit after signing in./login_refreshcalls while the JWT is valid.Checklist
⚠ Please make sure to fill this checklist before asking for reviews.
i.e.
feat(CUR-###): Feature title