Skip to content

fix(ENG38-1087): redirect to login when the learner has no session - #93

Merged
j0mc merged 1 commit into
redwood.masterfrom
feat/redirect-to-login-without-session
Dec 3, 2026
Merged

j0mc merged 1 commit into
redwood.masterfrom
feat/redirect-to-login-without-session

Conversation

@j0mc

@j0mc j0mc commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

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: true in initialize(). At startup, frontend-platform's ensureAuthenticatedUser() now redirects a learner with no session to LOGIN_URL, with a next parameter 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_refresh endpoint 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: requireAuthenticatedUser only 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:

  1. No session: in a private window, open a courseware URL such as /learning/course/<course-id>/<sequence-id>/<unit-id>. You should be redirected to login, and returned to that unit after signing in.
  2. Signed in: load and navigate courseware as usual. There should be no extra redirects, and no /login_refresh calls while the JWT is valid.
  3. JWT cookies deleted, session kept: navigate to another unit. New JWT cookies are issued silently, and the page keeps working.
  4. Session and JWT cookies both deleted mid-visit: navigate to another unit. The unit error panel appears, and "Try again" leads to login.

Checklist

⚠ Please make sure to fill this checklist before asking for reviews.

  • Code is correctly formatted and linted
  • Unit tests are updated and are passing
  • PR title follows conventional commits:
    i.e. feat(CUR-###): Feature title
  • PR Title aligns to Semantic-Release supported prefixes (NOTE: prefixes are case sensitive, keep lower-case)
  • Check for unused files
  • Check work before asking for reviewers
  • Fix any linting errors
  • SECURITY: No secrets where commited to the repo
  • COMPLIANCE: Commited code is not propietary and adheres to Open Source licensing

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.
@j0mc
j0mc merged commit be421ed into redwood.master Dec 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants