Skip to content

Commit

Permalink
Merge pull request #796 from crowdbotics/PI-258-add-allauth-middleware
Browse files Browse the repository at this point in the history
Add allauth AccountMiddleware to MIDDLEWARE list
  • Loading branch information
sgmagar authored Aug 13, 2024
2 parents 294bb65 + 8a57158 commit b9607d9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions {{cookiecutter.project_slug}}/home/api/v1/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from django.utils.translation import gettext_lazy as _
from allauth.account import app_settings as allauth_settings
from allauth.account.forms import ResetPasswordForm
from allauth.utils import email_address_exists, generate_unique_username
from allauth.utils import generate_unique_username
from allauth.account.utils import assess_unique_email
from allauth.account.adapter import get_adapter
from allauth.account.utils import setup_user_email
from rest_framework import serializers
Expand Down Expand Up @@ -38,7 +39,7 @@ def _get_request(self):
def validate_email(self, email):
email = get_adapter().clean_email(email)
if allauth_settings.UNIQUE_EMAIL:
if email and email_address_exists(email):
if email and assess_unique_email(email):
raise serializers.ValidationError(
_("A user is already registered with this e-mail address.")
)
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/home/templates/base.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% raw %}
{% load staticfiles %}
{% load static %}
<!doctype html>
<html lang="en">
<head>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% raw %}
{% extends '../base.html' %}
{% load staticfiles %}
{% load static %}
{% load bootstrap4 %}

{% block content %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'allauth.account.middleware.AccountMiddleware',
]

ROOT_URLCONF = '{{cookiecutter.project_slug}}.urls'
Expand Down Expand Up @@ -284,7 +285,7 @@
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"


# GCP config
# GCP config
def google_service_account_config():
# base64 encoded service_account.json file
service_account_config = env.str("GS_CREDENTIALS", "")
Expand Down

0 comments on commit b9607d9

Please sign in to comment.