From 7984cb5f0074658ee5021cc92b01177d759f228c Mon Sep 17 00:00:00 2001 From: ante Date: Fri, 2 Jan 2015 09:04:29 +0100 Subject: [PATCH] Test za DRF3 --- demo/demo/settings.py | 18 +++++++++++++++--- demo/demo/urls.py | 1 + rest_auth/views.py | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/demo/demo/settings.py b/demo/demo/settings.py index b0b3941..1bc1149 100644 --- a/demo/demo/settings.py +++ b/demo/demo/settings.py @@ -44,17 +44,20 @@ INSTALLED_APPS = ( 'django.contrib.staticfiles', 'django.contrib.sites', + 'corsheaders', + 'rest_framework', 'rest_framework.authtoken', 'rest_auth', - 'allauth', - 'allauth.account', - 'rest_auth.registration', + # 'allauth', + # 'allauth.account', + # 'rest_auth.registration', ) MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', + 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', @@ -105,3 +108,12 @@ SITE_ID = 1 ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_AUTHENTICATION_METHOD = 'email' ACCOUNT_EMAIL_VERIFICATION = 'mandatory' + +CORS_ORIGIN_ALLOW_ALL = True + +REST_FRAMEWORK = { + 'DEFAULT_AUTHENTICATION_CLASSES': ( + 'rest_framework.authentication.SessionAuthentication', + 'rest_framework.authentication.TokenAuthentication', + ) +} \ No newline at end of file diff --git a/demo/demo/urls.py b/demo/demo/urls.py index 42b4a88..1eb8778 100644 --- a/demo/demo/urls.py +++ b/demo/demo/urls.py @@ -33,5 +33,6 @@ urlpatterns = patterns('', url(r'^rest-auth/', include('rest_auth.urls')), url(r'^rest-auth/registration/', include('rest_auth.registration.urls')), + url(r'^account/', include('allauth.urls')), url(r'^admin/', include(admin.site.urls)), ) diff --git a/rest_auth/views.py b/rest_auth/views.py index 0f18fd5..05217cf 100644 --- a/rest_auth/views.py +++ b/rest_auth/views.py @@ -31,7 +31,7 @@ class Login(GenericAPIView): response_serializer = TokenSerializer def login(self): - self.user = self.serializer.object['user'] + self.user = self.serializer.validated_data['user'] self.token, created = self.token_model.objects.get_or_create( user=self.user) if getattr(settings, 'REST_SESSION_LOGIN', True):