1. Valentin Gorbunov
  2. django-publicauth

Source

django-publicauth / openauth / signals.py

from django.contrib import auth 

from annoying.decorators import signals
from confirmation.models import Confirmation
from confirmation.signals import successfull_confirmation

from openauth import settings


@signals(successfull_confirmation, sender=Confirmation)
def sighandler(request, instance, confirmation_type, **kwargs):
    if confirmation_type == settings.ACTIVATION_TYPE:
        user = instance
        user.is_active = True
        user.save()
        if settings.ACTIVATION_AUTO_LOGIN:
            user.backend = 'django.contrib.auth.backends.ModelBackend'
            auth.login(request, user)