From 74087cff261b32557a78666cb53cf0aeedf46a24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bompard?= Date: Mon, 17 Jul 2017 15:13:25 +0000 Subject: [PATCH] HyperKitty: disable local signup Spamming reasons, see puiterwijk. --- roles/mailman/files/django_fedora.py | 16 ++++++++++++++++ roles/mailman/templates/settings.py.j2 | 7 +++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/roles/mailman/files/django_fedora.py b/roles/mailman/files/django_fedora.py index b8cda8a077..87fc33924c 100644 --- a/roles/mailman/files/django_fedora.py +++ b/roles/mailman/files/django_fedora.py @@ -13,3 +13,19 @@ def exclude_useless_errors(record): if isinstance(exc_value, excluded_class): return False return True + + +# Disable local signup + +from allauth.account.adapter import DefaultAccountAdapter +from allauth.socialaccount.adapter import DefaultSocialAccountAdapter + +class NoLocalSignUpAdapter(DefaultAccountAdapter): + + def is_open_for_signup(self, request): + return False + +class SignUpEnabledSocialAdapter(DefaultSocialAccountAdapter): + + def is_open_for_signup(self, request): + return True diff --git a/roles/mailman/templates/settings.py.j2 b/roles/mailman/templates/settings.py.j2 index 89455760ff..19b2039997 100644 --- a/roles/mailman/templates/settings.py.j2 +++ b/roles/mailman/templates/settings.py.j2 @@ -6,8 +6,6 @@ Django settings for HyperKitty + Postorius import os BASE_DIR = os.path.dirname(os.path.abspath(__file__)) -import django_fedora - # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '{{ mailman_hyperkitty_cookie_key }}' @@ -241,6 +239,9 @@ ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_EMAIL_VERIFICATION = "mandatory" ACCOUNT_DEFAULT_HTTP_PROTOCOL = "https" ACCOUNT_UNIQUE_EMAIL = True +# Disable local signup +ACCOUNT_ADAPTER = "django_fedora.NoLocalSignUpAdapter" +SOCIALACCOUNT_ADAPTER = "django_fedora.SignUpEnabledSocialAdapter" SOCIALACCOUNT_PROVIDERS = { 'openid': { @@ -336,6 +337,8 @@ REST_FRAMEWORK = { } +import django_fedora + # A sample logging configuration. The only tangible logging # performed by this configuration is to send an email to # the site admins on every HTTP 500 error when DEBUG=False.