- March 15, 2010
- login auth django-registration
- 7 (after 7 ratings)
Here's a signal handler to log a user in on registration activation. It took me an hour to figure out that I needed to put the user.backend in quotes and google wasn't being my friend.
from the django-registration documentation: How do I log a user in immediately after registration or activation? You can most likely do this simply by writing a function which listens for the appropriate signal; your function should set the backend attribute of the user to the correct authentication backend, and then call django.contrib.auth.login() to log the user in.
1 2 3 4
def login_on_activation(sender, user, request, **kwargs): user.backend='django.contrib.auth.backends.ModelBackend' login(request,user) user_activated.connect(login_on_activation)
More like this
- Log in a user without requiring credentials by SmileyChris 6 years, 12 months ago
- Show logged users - keeping track of users login and logout by albertorcf 3 years, 8 months ago
- easy signal registration by aisbaa 4 years, 7 months ago
- Registration with confirmation email by catellar 4 years, 9 months ago
- Binding signals to abstract models by andreterra 4 years ago