0.11.0 Google Auth

This commit is contained in:
SDE
2024-01-13 14:49:32 +03:00
parent bf18c96dbd
commit 2e1f3a10ab
4 changed files with 32 additions and 4 deletions

View File

@@ -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'

View File

@@ -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')),

View File

@@ -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

View File

@@ -1,12 +1,13 @@
{% load i18n %}
{% load socialaccount %}
{% trans "Логин" as p_login %}
{% trans "Пароль" as p_password %}
<section class="login">
<h1>{% translate "Войдите в профиль" %}</h1>
<h1>{% translate "Войдите в профиль" %}</h1>
<form class="login_form" name="login_form" method="post">
<form class="login_form" name="login_form" method="post">
{% csrf_token %}
<div>
{% if form.errors.all__ %}
@@ -31,7 +32,7 @@
<div class="agree_text_l">{% translate "Авторизуясь, вы соглашаетесь с Лицензионным соглашением Политикой конфиденциальности" %}</div>
<div id="reg_or_text">{% translate "Или" %}</div>
<a href="{% url 'social:begin' 'google-oauth2' %}">
<a href="{% provider_login_url 'google' %}">
<div id = "google_text" class="google"><img src="/static/img/png/google.png" alt="">
<div> {% translate "Войти через" %} Google</div>
</div>