Commits

Nick Meharry committed 23088f4

Automatically log the user in after activation.

Comments (0)

Files changed (1)

registration/signals.py

+from django.contrib.auth import login, get_backends
 from django.dispatch import Signal
 
 
 
 # A user has activated his or her account.
 user_activated = Signal(providing_args=["user", "request"])
+
+def log_in_user(sender, user, request, **kwargs):
+    backend = get_backends()[0] # A bit of a hack to bypass `authenticate()`.
+    user.backend = "%s.%s" % (backend.__module__, backend.__class__.__name__)
+    login(request, user)
+user_activated.connect(log_in_user)