diff --git a/cosmos_search/settings.py b/cosmos_search/settings.py index ae5400d..9c13108 100644 --- a/cosmos_search/settings.py +++ b/cosmos_search/settings.py @@ -13,7 +13,7 @@ import os from decouple import config, Csv - +#from django.contrib.sites.models import Site # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) @@ -53,8 +53,28 @@ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'django.contrib.sites', + 'allauth', + 'allauth.account', + 'allauth.socialaccount', + #'allauth.socialaccount.providers.facebook', + 'allauth.socialaccount.providers.google', + #'allauth.socialaccount.providers.twitter', ] +SITE_ID = 2 + +SOCIALACCOUNT_PROVIDERS = {'facebook': {}, 'google': + + { 'SCOPE': ['email', + 'https://www.googleapis.com/auth/userinfo.email', + 'https://www.googleapis.com/auth/userinfo.profile', + 'https://www.googleapis.com/auth/plus.login', + 'https://www.googleapis.com/auth/plus.me',], + + 'AUTH_PARAMS': { 'access_type': 'online' } + }, 'twitter':{}} + MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', @@ -70,7 +90,8 @@ TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], + 'DIRS': [os.path.join(BASE_DIR, "templates")], + # 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ @@ -78,11 +99,23 @@ 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', + 'django.template.context_processors.i18n', + # Required by allauth template tags + # "django.core.context_processors.request", + # 'allauth.account.context_processors.account', + # 'allauth.socialaccount.context_processors.socialaccount' ], }, }, ] +AUTHENTICATION_BACKENDS = ( + # Default backend -- used to login by username in Django admin + "django.contrib.auth.backends.ModelBackend", + # `allauth` specific authentication methods, such as login by e-mail + "allauth.account.auth_backends.AuthenticationBackend", +) + WSGI_APPLICATION = 'cosmos_search.wsgi.application' @@ -129,6 +162,11 @@ USE_TZ = True +ACCOUNT_USERNAME_REQUIRED = False +ACCOUNT_EMAIL_VERIFICATION = "none" +SOCIALACCOUNT_QUERY_EMAIL = True +LOGIN_REDIRECT_URL = "/" +SOCIALACCOUNT_AUTO_SIGNUP = False # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.11/howto/static-files/ diff --git a/cosmos_search/urls.py b/cosmos_search/urls.py index 67ff007..a98a271 100644 --- a/cosmos_search/urls.py +++ b/cosmos_search/urls.py @@ -29,6 +29,8 @@ url(r'^', include('search.urls')), url(r'^update/', include('update.urls')), url(r'^admin/', admin.site.urls), + # url(r'^accounts/', include('django.contrib.auth.urls')), + url(r'^accounts/', include('allauth.urls')), ] if settings.DEBUG: @@ -42,3 +44,4 @@ handler403 = views.error403 # noqa handler404 = views.error404 # noqa handler500 = views.error500 # noqa + diff --git a/requirements.txt b/requirements.txt index 934517c..f17bfbb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,3 +12,4 @@ smmap2==2.0.3 urllib3==1.22 pep8==1.7.1 python-decouple==3.1 +django-allauth==0.32.0 \ No newline at end of file diff --git a/search/templates/cosmos/header.html b/search/templates/cosmos/header.html index 135de8f..7f8c631 100644 --- a/search/templates/cosmos/header.html +++ b/search/templates/cosmos/header.html @@ -11,6 +11,7 @@ + {% block style %} {% endblock %} @@ -71,9 +74,58 @@ cosmos-search