(backend) support email anonymization on user

Add a new property 'email_anonymized' to the User model,
to allow tracking a user's email without any personal data.

In fact, we're dealing with professional data, thus it shouldn't
be subject to the GDPR, however I prefer taking extra care
when working with potentially first and last names.
This commit is contained in:
lebaudantoine
2024-08-03 23:14:01 +02:00
committed by aleb_the_flash
parent a992aa8898
commit fc232759fb
2 changed files with 16 additions and 0 deletions

View File

@@ -163,6 +163,13 @@ class User(AbstractBaseUser, BaseModel, auth_models.PermissionsMixin):
"""
return []
@property
def email_anonymized(self):
"""Anonymize the email address by replacing the local part with asterisks."""
if not self.email:
return ""
return f"***@{self.email.split('@')[1]}"
class Resource(BaseModel):
"""Model to define access control"""