Skip to content

Commit

Permalink
Make login a utility so it can be re-used elsewhere.
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Lamb <chris@playfire.com>
  • Loading branch information
lamby committed Jan 17, 2012
1 parent 57ed68e commit 81aa359
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions django_autologin/utils.py
@@ -1,6 +1,9 @@
import urllib import urllib
import urlparse import urlparse


from django.conf import settings
from django.contrib import auth

from . import app_settings from . import app_settings


def strip_token(url): def strip_token(url):
Expand All @@ -17,3 +20,7 @@ def strip_token(url):
return urlparse.urlunparse( return urlparse.urlunparse(
(bits[0], bits[1], bits[2], bits[3], query, bits[5]), (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.