adamcharnock/django-su — pull request #25 by johnsmclay (2014-05-01 23:24:04+00:00)
Title: Added the ability to override the auth.login function

When my users login I set some session data like if they have access to multiple clients what client they are currently working with so I know what data to show them. Also I clear a failed login counter and some other things. My problem was that the django_su module skipped these things all together which caused problems elsewhere. I added the ability to specify in settings something like ```SU_CUSTOM_LOGIN_ACTION = 'myapp.auth.login'``` and on login django_su will call that function instead of django.contrib.auth.login(request, user). The override function wil need to accept the request and user vars and call the django.contrib.auth.login(request, user) method somewhere in it.
Example:
```
def login(request, user):
auth_login(request, user)
primary_widget = user.get_primary_widget()
request.session['current_widget_id'] = primary_widget.id
request.session.modified = True
if user.failed_login_count > 0:
user.failed_login_count = 0
user.save()
return True
```