Commit 08355a9c authored by Luis García's avatar Luis García
Browse files

Changes for social login

parent e2f12a6c
......@@ -34,18 +34,27 @@ ALLOWED_HOSTS = config('ALLOWED_HOSTS', cast=Csv())
# Application definition
INSTALLED_APPS = [
'registration',
#'registration',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.twitter',
'rest_auth.registration',
'django_extensions',
'django_filters',
'django_crontab',
'rest_auth',
'social_django',
'rest_framework',
'rest_framework.authtoken',
'rest_framework_gis',
'rest_framework_jwt',
'drf_yasg',
......@@ -267,8 +276,8 @@ MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media').encode('utf-8').strip()
#Redirect links
LOGIN_REDIRECT_URL = 'blog:home'
LOGOUT_REDIRECT_URL = 'blog:home'
LOGIN_REDIRECT_URL = '/'
LOGOUT_REDIRECT_URL = '/'
#Number of days for activate the account
ACCOUNT_ACTIVATION_DAYS = 7
......@@ -312,4 +321,6 @@ CRONJOBS = [
#Cors options
CORS_ORIGIN_ALLOW_ALL = True
#CORS_ALLOW_CREDENTIALS = True
\ No newline at end of file
#CORS_ALLOW_CREDENTIALS = True
REST_USE_JWT = True
\ No newline at end of file
......@@ -29,6 +29,8 @@ from api.urls import api_patterns
from django.views.i18n import JavaScriptCatalog
from registration.views import CustomActivationView
from core.views.social_auth import FacebookLogin, TwitterLogin
"""urlpatterns = [
path('page/', include(pages_patterns)),
path('api/', include(api_patterns)),
......@@ -51,6 +53,10 @@ urlpatterns += [
url(r'^token-refresh/', refresh_jwt_token),
url(r'^token-verify/', verify_jwt_token),
url(r'^oauth/', include('social_django.urls', namespace='social')),
url(r'^rest-auth/', include('rest_auth.urls')),
url(r'^rest-auth/facebook/$', FacebookLogin.as_view(), name='fb_login'),
url(r'^rest-auth/twitter/$', TwitterLogin.as_view(), name='twitter_login')
#url(r'^auth/', include('rest_framework_social_oauth2.urls')),
]
"""urlpatterns += i18n_patterns(
......
from allauth.socialaccount.providers.facebook.views import FacebookOAuth2Adapter
from allauth.socialaccount.providers.twitter.views import TwitterOAuthAdapter
from rest_auth.registration.views import SocialLoginView
from rest_auth.social_serializers import TwitterLoginSerializer
class FacebookLogin(SocialLoginView):
adapter_class = FacebookOAuth2Adapter
from rest_auth.registration.views import SocialLoginView
class TwitterLogin(SocialLoginView):
serializer_class = TwitterLoginSerializer
adapter_class = TwitterOAuthAdapter
\ No newline at end of file
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