From 50612a44fc590fd746e2eceef74e344b5c7506c2 Mon Sep 17 00:00:00 2001
From: Tom Teichler <tom.teichler@teckids.org>
Date: Fri, 4 Mar 2022 18:32:07 +0100
Subject: [PATCH] Do not override account adapter for invitations

---
 CHANGELOG.rst                     | 5 +++++
 aleksis/core/settings.py          | 2 --
 aleksis/core/util/auth_helpers.py | 4 ++--
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index a46793f6b..6a3521ecb 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -9,6 +9,11 @@ and this project adheres to `Semantic Versioning`_.
 Unreleased
 ----------
 
+Fixed
+~~~~~
+
+* ACCOUNT_ADAPTER was overriden by invitations
+
 Added
 ~~~~~
 
diff --git a/aleksis/core/settings.py b/aleksis/core/settings.py
index 00c0a6605..17ac7a96f 100644
--- a/aleksis/core/settings.py
+++ b/aleksis/core/settings.py
@@ -367,8 +367,6 @@ ACCOUNT_USERNAME_VALIDATORS = "aleksis.core.util.auth_helpers.custom_username_va
 
 # Configuration for django-invitations
 
-# Use custom account adapter
-ACCOUNT_ADAPTER = "invitations.models.InvitationsAdapter"
 # Expire invitations are configured amout of days
 INVITATIONS_INVITATION_EXPIRY = _settings.get("auth.invitation.expiry", 3)
 # Use email prefix configured for django-allauth
diff --git a/aleksis/core/util/auth_helpers.py b/aleksis/core/util/auth_helpers.py
index 6edfac833..a27910250 100644
--- a/aleksis/core/util/auth_helpers.py
+++ b/aleksis/core/util/auth_helpers.py
@@ -7,8 +7,8 @@ from django.contrib.auth.validators import ASCIIUsernameValidator
 from django.core.validators import RegexValidator
 from django.http import HttpRequest
 
-from allauth.account.adapter import DefaultAccountAdapter
 from allauth.socialaccount.adapter import DefaultSocialAccountAdapter
+from invitations.models import InvitationsAdapter
 from oauth2_provider.models import AbstractApplication
 from oauth2_provider.oauth2_validators import OAuth2Validator
 from oauth2_provider.scopes import BaseScopes
@@ -37,7 +37,7 @@ class OurSocialAccountAdapter(DefaultSocialAccountAdapter):
         return super().validate_disconnect(account, accounts)
 
 
-class OurAccountAdapter(DefaultAccountAdapter):
+class OurAccountAdapter(InvitationsAdapter):
     """Customised adapter to allow to disable signup."""
 
     def is_open_for_signup(self, request):
-- 
GitLab