Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Luis García
collabmap
Commits
08355a9c
Commit
08355a9c
authored
Feb 20, 2020
by
Luis García
Browse files
Changes for social login
parent
e2f12a6c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
4 deletions
+35
-4
collabmap/settings.py
collabmap/settings.py
+15
-4
collabmap/urls.py
collabmap/urls.py
+6
-0
core/views/social_auth.py
core/views/social_auth.py
+14
-0
No files found.
collabmap/settings.py
View file @
08355a9c
...
...
@@ -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
collabmap/urls.py
View file @
08355a9c
...
...
@@ -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(
...
...
core/views/social_auth.py
0 → 100644
View file @
08355a9c
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment