Fixing SocialLoginSerializer

This commit is contained in:
ante 2015-01-03 19:04:50 +01:00
parent 54fb1de5d2
commit e5f1bf62ab
3 changed files with 9 additions and 8 deletions

View File

@ -44,7 +44,6 @@ INSTALLED_APPS = (
'django.contrib.staticfiles',
'django.contrib.sites',
'corsheaders',
'rest_framework',
'rest_framework.authtoken',
@ -57,7 +56,7 @@ INSTALLED_APPS = (
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',

View File

@ -7,7 +7,9 @@ class SocialLoginSerializer(serializers.Serializer):
access_token = serializers.CharField(required=True)
def validate_access_token(self, value):
def validate(self, attrs):
access_token = attrs['access_token']
view = self.context.get('view')
request = self.context.get('request')
@ -22,12 +24,12 @@ class SocialLoginSerializer(serializers.Serializer):
self.adapter = self.adapter_class()
app = self.adapter.get_provider().get_app(request)
token = self.adapter.parse_token({'access_token': value})
token = self.adapter.parse_token({'access_token': access_token})
token.app = app
try:
login = self.adapter.complete_login(request, app, token,
response=value)
response=access_token)
token.account = login.account
login.token = token
complete_social_login(request, login)
@ -37,6 +39,6 @@ class SocialLoginSerializer(serializers.Serializer):
if not login.is_existing:
login.lookup()
login.save(request, connect=True)
self.object = {'user': login.account.user}
attrs['user'] = login.account.user
return value
return attrs

View File

@ -75,5 +75,5 @@ ACCOUNT_ACTIVATION_DAYS = 1
SITE_ID = 1
MIGRATION_MODULES = {
'rest_framework.authtoken': 'rest_framework.authtoken.migrations',
'authtoken': 'authtoken.migrations',
}