diff --git a/TWB/settings.py b/TWB/settings.py index f77f3e4..3333833 100644 --- a/TWB/settings.py +++ b/TWB/settings.py @@ -36,6 +36,25 @@ WEBPUSH_SETTINGS = { "VAPID_ADMIN_EMAIL": "admin@tripwb.com" } +AUTHENTICATION_BACKENDS = [ + 'django.contrib.auth.backends.ModelBackend', + 'allauth.account.auth_backends.AuthenticationBackend', +] + + + +SOCIALACCOUNT_PROVIDERS = { + 'google': { + 'SCOPE': [ + 'profile', + 'email', + ], + 'AUTH_PARAMS': { + 'access_type': 'online', + }, + } +} + # NOTIFICATION_KEY = 'BJLyGzmo8sLI3Qkc6pN2cz11frCXiJdewvgve7Yps-_fM1lY1LSnTQfQxYtAgQ_26nAji_rgeYC1DkLiTwxw0Mo' # SESSION_COOKIE_HTTPONLY = False @@ -63,6 +82,11 @@ INSTALLED_APPS = [ 'webpush', + 'allauth', + 'allauth.account', + 'allauth.socialaccount', + 'allauth.socialaccount.providers.google', + 'GeneralApp', 'AuthApp', 'RoutesApp', @@ -82,6 +106,8 @@ MIDDLEWARE = [ 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'AuthApp.middleware.ResponseInterceptionMiddleware', + + "allauth.account.middleware.AccountMiddleware", ] ROOT_URLCONF = 'TWB.urls' diff --git a/TWB/urls.py b/TWB/urls.py index c772353..a40b35d 100644 --- a/TWB/urls.py +++ b/TWB/urls.py @@ -12,7 +12,7 @@ urlpatterns = [ path('ckeditor/', include('ckeditor_uploader.urls')), path('i18n/', include('django.conf.urls.i18n')), - # path('webpush/', include('webpush.urls')), + path('accounts/', include('allauth.urls')), path('messages/', include('ChatServiceApp.urls')), diff --git a/requirements.pip b/requirements.pip index 618a0c6..75932d7 100644 --- a/requirements.pip +++ b/requirements.pip @@ -11,4 +11,5 @@ daphne==4.0.0 channels-redis==4.1.0 django-colorfield django-webpush==0.3.5 +django-allauth==0.60.0 diff --git a/templates/forms/f_login.html b/templates/forms/f_login.html index dfe923b..81368bb 100644 --- a/templates/forms/f_login.html +++ b/templates/forms/f_login.html @@ -1,12 +1,13 @@ {% load i18n %} +{% load socialaccount %} {% trans "Логин" as p_login %} {% trans "Пароль" as p_password %}
-

{% translate "Войдите в профиль" %}

+

{% translate "Войдите в профиль" %}

-
+ {% csrf_token %}
{% if form.errors.all__ %} @@ -31,7 +32,7 @@
{% translate "Авторизуясь, вы соглашаетесь с Лицензионным соглашением Политикой конфиденциальности" %}
{% translate "Или" %}
- +
{% translate "Войти через" %} Google