Repository navigation
fix: LP-1617 activate inactive users on SSO login when the LMS account is active - #18
Merged
Merged
Conversation
…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>
abhalsod-sonata
approved these changes
Nov 30, 2026
abhalsod-sonata
left a comment
Member
There was a problem hiding this comment.
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>
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.
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_CREATEDevent carries the LMSis_active, andget_or_create_user_from_event_datacopies it when it creates the Credentials user. Nothing sets it back later: social-core'suser_detailsstep treatsis_activeas protected, and our own pipeline steps only update email, full name andlms_user_id. So after the learner activates their LMS account, social-auth still sees an inactive user and sends them toLOGIN_URL, which starts the SSO again.make_is_active_match_platformfixes the users who are stuck when it runs, but new ones keep arriving.Fix. A new pipeline step,
update_is_active, runs afterupdate_lms_user_id.user.is_activein the access token'semail_verifiedclaim. When the Credentials user is inactive and that claim is true, the step activates the user.email_verifiedfrom 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
/login/→/complete/edx-oauth2/flow, with only the LMS token request mocked:next./login/?next=….'/login/?next=/records/' != '/records/', which is the loop seen in production.Ticket: LP-1617 (root cause of LP-1449)
🤖 Generated with Claude Code