Repository navigation
feat: add command to release a retired learner's email for reuse - #39311
Open
rahulkanneri-2u wants to merge 2 commits into
Open
rahulkanneri-2u wants to merge 2 commits into
rahulkanneri-2u wants to merge 2 commits into
Conversation
This branch has not been deployed
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.
Description
A retired learner's original email is permanently blocked from re-registration, because
is_email_retired()still finds aUserrow whose email equals the salted retired hash of that address.This adds:
release_retired_learner_email(user)inopenedx/core/djangoapps/user_api/accounts/utils.py. It replaces the retired-hash email on the learner'sauth_userrow with a placeholder,retired__uid_<user_id>@<RETIRED_EMAIL_DOMAIN>. That clears the match, so the original address can be used for a new account.emailcolumn. TheUserRetirementStatusrow and retirement history are left untouched.select_for_update(), so it can't interleave with a concurrenthandle_retirement_cancellation()or another release for the same user.COMPLETEstate. If the status row has already been archived and deleted, it falls back to checking that the email is still in the retired-email domain. Otherwise it raisesRetirementStateError.A
release_retired_user_emailmanagement command that wraps the function for operator/support use:The command takes
--user_idonly, not a username, to avoid taking PII as input for a retired-learner tool.There is no automatic trigger. This is manual only.
Impacted roles: Operator / Support (the command), and indirectly Learners who want to reuse a previously retired email.
Supporting information
Testing instructions
Run the tests:
Manual check in an LMS shell:
COMPLETE.is_email_retired('<original email>')isTrue../manage.py lms release_retired_user_email --user_id <id>.retired__uid_<id>@retired.invalidandis_email_retired('<original email>')isFalse.Run the command against a user whose retirement is still in progress (for example
RETIRING_LMS), or one that isn't retired. It should fail with aCommandErrorand leave the email unchanged.Deadline
None
Other information
settings.RETIRED_EMAIL_DOMAIN, so it stays consistent with what the retirement code treats as "retired" on a given deployment.auth_userrow, as retirement intends.