Commit 0fb2d27b authored by Sharad Heft's avatar Sharad Heft
Browse files

Refactor some of the profile retrieval code.

parent 8b5c4705
......@@ -6,16 +6,19 @@ from django.db import transaction
from test_oauth.models import TESTOAuth2Data, Character
from test_oauth.session import TESTOAuth2Session
class TESTOAuth2Backend(ModelBackend):
def authenticate(self, token=None, id=None, username=None, **profile):
if id is None or username is None or token is None:
def authenticate(self, token=None, **kwargs):
if token is None:
return None
profile = TESTOAuth2Session(token=token).profile
user, _ = get_user_model().objects.get_or_create(
data, _ = TESTOAuth2Data.objects.update_or_create(
......@@ -29,8 +29,6 @@ def callback(request):
session = TESTOAuth2Session(token=token)
auth.login(request, auth.authenticate(token=token, **session.profile))
auth.login(request, auth.authenticate(token=token))
return redirect(getattr(settings, 'TEST_OAUTH_REDIRECT', '/'))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment