Permalink
Browse files

Make login a utility so it can be re-used elsewhere.

Signed-off-by: Chris Lamb <chris@playfire.com>
  • Loading branch information...
1 parent 57ed68e commit 81aa35961ba9552701eecbdb4d8e91448835aba0 @lamby lamby committed Jan 17, 2012
Showing with 7 additions and 0 deletions.
  1. +7 −0 django_autologin/utils.py
View
7 django_autologin/utils.py
@@ -1,6 +1,9 @@
import urllib
import urlparse
+from django.conf import settings
+from django.contrib import auth
+
from . import app_settings
def strip_token(url):
@@ -17,3 +20,7 @@ def strip_token(url):
return urlparse.urlunparse(
(bits[0], bits[1], bits[2], bits[3], query, bits[5]),
)
+
+def login(request, user):
+ user.backend = settings.AUTHENTICATION_BACKENDS[0]
+ auth.login(request, user)

0 comments on commit 81aa359

Please sign in to comment.