Skip to content

fix: LP-1617 activate inactive users on SSO login when the LMS account is active - #18

Merged
Alam-2U merged 2 commits into
release-ulmofrom
ealam/LP-1617-activate-user-on-login
Dec 3, 2026
Merged

Alam-2U merged 2 commits into
release-ulmofrom
ealam/LP-1617-activate-user-on-login

Conversation

@Alam-2U

@Alam-2U Alam-2U commented Nov 30, 2026 •

Copy link
Copy Markdown

Summary

Fixes learners getting ERR_TOO_MANY_REDIRECTS on their program certificate and record links because their Credentials user has is_active = 0.

Root cause. The LMS lets learners earn certificates before they activate their account. The CERTIFICATE_CREATED event carries the LMS is_active, and get_or_create_user_from_event_data copies it when it creates the Credentials user. Nothing sets it back later: social-core's user_details step treats is_active as protected, and our own pipeline steps only update email, full name and lms_user_id. So after the learner activates their LMS account, social-auth still sees an inactive user and sends them to LOGIN_URL, which starts the SSO again. make_is_active_match_platform fixes the users who are stuck when it runs, but new ones keep arriving.

Fix. A new pipeline step, update_is_active, runs after update_lms_user_id.

  • The LMS puts its user.is_active in the access token's email_verified claim. When the Credentials user is inactive and that claim is true, the step activates the user.
  • It runs before social-auth's active check, so the learner gets in on that same login. That includes users who are already stuck.
  • Like the management command, it only goes from inactive to active.
  • edx-auth-backends drops email_verified from the user details, so the step decodes the access token itself, the same way edx-auth-backends reads the other claims (the token comes straight from the LMS token endpoint). If there's no token or it can't be decoded, the step does nothing.

Not changed. A learner who still hasn't activated their LMS account keeps looping until they do.

Testing

  • Unit tests for the step: LMS account active, LMS account inactive, claim missing, no or bad token, user already active, no user.
  • Two tests run the real /login/ → /complete/edx-oauth2/ flow, with only the LMS token request mocked:
    • An inactive user whose LMS account is active is logged in and lands on next.
    • An inactive user whose LMS account is inactive is sent to /login/?next=….
  • With the step removed from the pipeline, the first flow test fails with '/login/?next=/records/' != '/records/', which is the loop seen in production.

Ticket: LP-1617 (root cause of LP-1449)

🤖 Generated with Claude Code

…t is active

Credentials creates a user from an LMS certificate event with the LMS
is_active value. A learner who earns a certificate before activating
their LMS account is created inactive, and nothing sets it back, so
after they activate, social-auth keeps sending them to /login/ in a
loop.

Add an update_is_active step to SOCIAL_AUTH_PIPELINE. It reads the
access token's email_verified claim, which the LMS sets from
user.is_active, and activates the user when it is true. Like
make_is_active_match_platform, it only goes from inactive to active.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread credentials/apps/core/utils.py Resolved

@abhalsod-sonata abhalsod-sonata left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve. The step is small, runs only for inactive users, and only goes from inactive to active. Decoding the token without a signature check is the same as EdXOAuth2.user_data in edx-auth-backends 5.1.1, so it adds no new trust. Two small comments inline.

AI disclosure: this review was drafted with Claude Code (Anthropic). I read the diff, the surrounding code, the edx-auth-backends, social-core and PyJWT sources, and the LMS code that sets email_verified. I did not run the tests or the login flow. CI is green.

core/utils.py now imports jwt directly, so pyjwt belongs in base.in
instead of arriving only through other packages. base.txt is recompiled
without --upgrade: no pin changes, only pyjwt's "via" list. The other
requirements files come out the same.

LoginPipelineTests has no @ddt.data test, so its @ddt.ddt did nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Alam-2U
Alam-2U merged commit 33b2802 into release-ulmo Dec 3, 2026
5 checks passed
@Alam-2U
Alam-2U deleted the ealam/LP-1617-activate-user-on-login branch December 3, 2026 06:29
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.

2 participants