Privacy

Anonymization

User privacy is important, not only to meet local regulations, but also to protect your users and allow them to exercise their rights. However, it’s not always practical to delete users, especially if they have dependent objects, that are relevant for statistical analysis.

Anonymization is a process of removing the user’s personal data whilst keeping related data intact. This is done by using the anomymize method.

AbstractEmailUser.anonymize(commit=True)

Anonymize the user data for privacy purposes.

This method will erase the email address, first and last name. You may overwrite this method to add additional fields to anonymize:

class MyUser(AbstractEmailUser):
    def anonymize(self, commit=True):
        super().anonymize(commit=False) # do not commit yet
        self.phone_number = None
        if commit:
            self.save()

This method may be overwritten to provide anonymization for you custom user model.

Related objects may also listen to the anonymize signal.

mailauth.contrib.user.signals.anonymize

Signal that is emitted when a user and all their data should be anonymized.

The signal is emitted before the private date is delete on the instance, thus the receiver can still access the data. The receiver should usually not alter the instance, but only later related data. We recommend overriding the anonymize method to modify the instance.

Usage:

from django.dispatch import receiver
from mailauth.contrib.user.models import EmailUser
from mailauth.contrib.user.signals import anonymize


@receiver(anonymize, sender=EmailUser)
def anonymize_user(sender, instance, **kwargs):
    # Do something with related user data
    instance.related_model.delete()

All those methods can be conveniently triggered via the anonymize admin action.

class mailauth.contrib.user.admin.AnonymizableAdminMixin

Bases: object

Mixin for admin classes that provides a anonymize action.

This mixin calls the anonymize method of all user model instances.

Liability Waiver

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.