From dac078f7dbf5d6cebd286eb62370f124cc934790 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Mon, 11 Oct 2021 12:55:46 +0200 Subject: [PATCH] Add Django-AllAuth app --- photo21/settings.py | 17 ++++++++++++++++- photo21/urls.py | 3 +-- requirements.txt | 1 + 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/photo21/settings.py b/photo21/settings.py index df7257a..fefc612 100644 --- a/photo21/settings.py +++ b/photo21/settings.py @@ -41,6 +41,9 @@ INSTALLED_APPS = [ 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', + 'allauth', + 'allauth.account', + 'allauth.socialaccount', 'crispy_forms', 'photologue_custom', 'photologue', @@ -81,6 +84,14 @@ TEMPLATES = [ }, ] +AUTHENTICATION_BACKENDS = [ + # Needed to login by username in Django admin, regardless of `allauth` + 'django.contrib.auth.backends.ModelBackend', + + # `allauth` specific authentication methods, such as login by e-mail + 'allauth.account.auth_backends.AuthenticationBackend', +] + WSGI_APPLICATION = 'photo21.wsgi.application' @@ -168,7 +179,11 @@ SESSION_COOKIE_AGE = 60 * 60 * 3 # Use only one Django Sites SITE_ID = 1 -# use Bootstrap forms +# Allauth configuration +ACCOUNT_EMAIL_REQUIRED = True +ACCOUNT_EMAIL_VERIFICATION = "mandatory" + +# Use Bootstrap forms CRISPY_TEMPLATE_PACK = 'bootstrap4' # Photologue diff --git a/photo21/urls.py b/photo21/urls.py index 311d17b..d3ffe9d 100644 --- a/photo21/urls.py +++ b/photo21/urls.py @@ -25,8 +25,7 @@ urlpatterns = [ path('', IndexView.as_view(), name='index'), path('photologue/', include('photologue_custom.urls')), path('photologue/', include('photologue.urls', namespace='photologue')), - path('accounts/', include('django.contrib.auth.urls')), - path('accounts/', include('accounts.urls')), + path('accounts/', include('allauth.urls')), path('i18n/', include('django.conf.urls.i18n')), path('admin/', admin.site.urls), path('admin/doc/', include('django.contrib.admindocs.urls')), diff --git a/requirements.txt b/requirements.txt index 64cb7df..9dc17a5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ Django~=2.2.20 django-photologue~=3.13 django-taggit>=0.24.0 django-crispy-forms~=1.7 +django-allauth>=0.44