Skip to content

Commit

Permalink
only bind signal if REGISTRATION_AUTO_LOGIN True
Browse files Browse the repository at this point in the history
  • Loading branch information
macropin committed Oct 1, 2014
1 parent 53ce62d commit 623baa7
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions registration/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@

def login_user(sender, user, request, **kwargs):
""" Automatically authenticate the user when activated """
if getattr(settings, 'REGISTRATION_AUTO_LOGIN', False ):
backend = get_backends()[0] # Hack to bypass `authenticate()`.
user.backend = "%s.%s" % (backend.__module__, backend.__class__.__name__)
login(request, user)
request.session['REGISTRATION_AUTO_LOGIN'] = True
request.session.modified = True
user_activated.connect(login_user)
backend = get_backends()[0] # Hack to bypass `authenticate()`.
user.backend = "%s.%s" % (backend.__module__, backend.__class__.__name__)
login(request, user)
request.session['REGISTRATION_AUTO_LOGIN'] = True
request.session.modified = True

if getattr(settings, 'REGISTRATION_AUTO_LOGIN', False):
user_activated.connect(login_user)

0 comments on commit 623baa7

Please sign in to comment.