Skip to content

feat: redact PII fields before delete in user retirement flows#38426

Merged
robrap merged 40 commits into
openedx:masterfrom
ktyagiapphelix2u:ktyagi/primaryemail
Jun 1, 2026
Merged

feat: redact PII fields before delete in user retirement flows#38426
robrap merged 40 commits into
openedx:masterfrom
ktyagiapphelix2u:ktyagi/primaryemail

Conversation

@ktyagiapphelix2u
Copy link
Copy Markdown
Contributor

@ktyagiapphelix2u ktyagiapphelix2u commented Apr 23, 2026

Summary

Adds support for redacting sensitive PII fields before deletion in DeletableByUserValue models.

Changes include:

  • Added redact_before_delete_fields hook to model mixin
  • Redact emails before delete for:
    • CourseEnrollmentAllowed
    • PendingEmailChange
    • UnregisteredLearnerCohortAssignments
  • Added SQL assertion helpers to verify UPDATE occurs before DELETE
  • Added regression/unit tests for safe ID-filtered redaction and deletion flows
  • Updated email change flow to use delete_by_user_value

Ticket & Reference

https://2u-internal.atlassian.net/browse/BOMS-498

Related PR

https://2u-internal.atlassian.net/browse/BOMS-565
https://2u-internal.atlassian.net/browse/BOMS-564

@ktyagiapphelix2u ktyagiapphelix2u marked this pull request as ready for review April 23, 2026 11:29
@ktyagiapphelix2u ktyagiapphelix2u requested a review from a team as a code owner April 23, 2026 11:29
Comment thread common/djangoapps/student/tests/test_models.py Outdated
Comment thread common/djangoapps/student/models/user.py Outdated
Comment thread common/djangoapps/student/tests/test_models.py Outdated
Comment thread common/djangoapps/student/models/user.py Outdated
Comment thread common/djangoapps/student/tests/test_models.py Outdated
Comment thread common/djangoapps/student/models/user.py Outdated
Comment thread common/djangoapps/student/models/user.py Outdated
Comment thread openedx/core/djangoapps/user_api/accounts/views.py Outdated
@ktyagiapphelix2u ktyagiapphelix2u force-pushed the ktyagi/primaryemail branch 2 times, most recently from 0d5d5e6 to 2593ac2 Compare May 4, 2026 08:49
@vgulati-apphelix
Copy link
Copy Markdown
Contributor

This change addresses a privacy issue in the retirement flow for users who have a pending primary email change.

Please elaborate the problem statement and solution provided.

Comment thread common/djangoapps/student/models/user.py Outdated
Comment thread common/djangoapps/student/models/user.py Outdated
Comment thread openedx/core/djangoapps/user_api/accounts/views.py Outdated
Comment thread common/djangoapps/student/models/user.py Outdated
Comment thread common/djangoapps/student/tests/test_email.py Outdated
Comment thread common/djangoapps/student/tests/test_email.py Outdated
@ktyagiapphelix2u ktyagiapphelix2u changed the title fix: redact pending primary email before retirement deletion feat: redact PII fields before delete in user retirement flows May 22, 2026
Copy link
Copy Markdown
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

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

I didn't get through the review fully. Sorry. So just leaving you with what I have.

Comment thread common/djangoapps/student/models/course_enrollment.py Outdated
Comment thread common/djangoapps/student/tests/test_models.py Outdated
Comment thread common/djangoapps/student/views/management.py
Comment thread common/djangoapps/student/views/management.py
Comment thread openedx/core/djangoapps/course_groups/tests/test_cohorts.py Outdated
Copy link
Copy Markdown
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

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

Thanks. Is looking good and getting close. We're almost there.

Comment thread common/djangoapps/student/views/management.py Outdated
Comment thread common/djangoapps/student/views/management.py
Comment thread openedx/core/djangolib/testing/sql_assertions.py Outdated
Comment thread openedx/core/djangolib/model_mixins.py Outdated
Comment thread openedx/core/djangolib/tests/test_model_mixins.py Outdated
Comment thread openedx/core/djangolib/tests/test_model_mixins.py
Copy link
Copy Markdown
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

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

I didn't get through review, but here is something...

Comment thread openedx/core/djangolib/testing/sql_assertions.py Outdated
Comment thread openedx/core/djangolib/model_mixins.py Outdated
Copy link
Copy Markdown
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

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

@ktyagiapphelix2u: It's looking great. Very minor proposals. Let's try to look at your final changes together on Monday so we can merge. Thank you.

Comment thread openedx/core/djangolib/testing/sql_assertions.py Outdated
Comment thread openedx/core/djangolib/testing/sql_assertions.py Outdated
Comment thread openedx/core/djangolib/testing/sql_assertions.py Outdated
Comment thread openedx/core/djangolib/tests/test_model_mixins.py
Comment thread openedx/core/djangolib/model_mixins.py Outdated
Comment thread openedx/core/djangolib/model_mixins.py Outdated
Comment thread openedx/core/djangolib/testing/sql_assertions.py Outdated
Comment thread common/djangoapps/student/models/user.py
Comment thread openedx/core/djangolib/model_mixins.py Outdated
Copy link
Copy Markdown
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

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

Thanks for this @ktyagiapphelix2u. I'm happy to merge.

@robrap robrap enabled auto-merge (squash) June 1, 2026 14:22
@robrap robrap merged commit 82b77ae into openedx:master Jun 1, 2026
40 of 41 checks passed
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.

5 participants