From 472e27230594df92b152e94d24ca447600e5f992 Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Fri, 14 Apr 2023 19:56:41 +0200 Subject: [PATCH] Remove Twitter login, disable signups --- gnuviechadmin/gnuviechadmin/auth.py | 11 +++++ gnuviechadmin/gnuviechadmin/settings.py | 3 +- gnuviechadmin/templates/account/login.html | 47 +++++++++---------- .../socialaccount/snippets/provider_list.html | 40 ++++++++-------- 4 files changed, 56 insertions(+), 45 deletions(-) create mode 100644 gnuviechadmin/gnuviechadmin/auth.py diff --git a/gnuviechadmin/gnuviechadmin/auth.py b/gnuviechadmin/gnuviechadmin/auth.py new file mode 100644 index 0000000..f493471 --- /dev/null +++ b/gnuviechadmin/gnuviechadmin/auth.py @@ -0,0 +1,11 @@ +from allauth.account.adapter import DefaultAccountAdapter + + +class NoNewUsersAccountAdapter(DefaultAccountAdapter): + """ + Adapter to disable allauth new signups + + """ + + def is_open_for_signup(self, request): + return False diff --git a/gnuviechadmin/gnuviechadmin/settings.py b/gnuviechadmin/gnuviechadmin/settings.py index 5e3e890..b1a6d1c 100644 --- a/gnuviechadmin/gnuviechadmin/settings.py +++ b/gnuviechadmin/gnuviechadmin/settings.py @@ -216,7 +216,6 @@ ALLAUTH_APPS = ( "allauth.socialaccount", "allauth.socialaccount.providers.google", "allauth.socialaccount.providers.linkedin_oauth2", - "allauth.socialaccount.providers.twitter", ) # Apps specific for this project go here. @@ -251,9 +250,11 @@ MESSAGE_TAGS = { # ######### ALLAUTH CONFIGURATION +ACCOUNT_ADAPTER = "gnuviechadmin.auth.NoNewUsersAccountAdapter" ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_EMAIL_VERIFICATION = "mandatory" LOGIN_REDIRECT_URL = "/" +SOCIALACCOUNT_AUTO_SIGNUP = False SOCIALACCOUNT_QUERY_EMAIL = True # ######### END ALLAUTH CONFIGURATION diff --git a/gnuviechadmin/templates/account/login.html b/gnuviechadmin/templates/account/login.html index 88862b6..57f9b1c 100644 --- a/gnuviechadmin/templates/account/login.html +++ b/gnuviechadmin/templates/account/login.html @@ -5,32 +5,29 @@ {% block page_title %}{% trans "Sign In" %}{% endblock page_title %} {% block content %} -{% get_providers as socialaccount_providers %} -{% if socialaccount_providers %} -

{% blocktrans with site.name as site_name %}Please sign in with one -of your existing third party accounts. Or, sign up -for a {{site_name}} account and sign in below:{% endblocktrans %}

- - -

{% trans 'or' %}

-{% else %} -

{% blocktrans %}If you have not created an account yet, then please -sign up first.{% endblocktrans %}

-{% endif %} - -
- {% csrf_token %} - {{ form | crispy }} - {% if redirect_field_value %} - - {% endif %} - {% trans "Forgot Password?" %} - -
+ {% get_providers as socialaccount_providers %} +
+
+ +
+
+ {% if socialaccount_providers %} +
    + {% include "socialaccount/snippets/provider_list.html" with process="login" %} +
+ {% endif %} +
+
{% endblock %} {% block extra_js %} -{% include "socialaccount/snippets/login_extra.html" %} + {% include "socialaccount/snippets/login_extra.html" %} {% endblock extra_js %} diff --git a/gnuviechadmin/templates/socialaccount/snippets/provider_list.html b/gnuviechadmin/templates/socialaccount/snippets/provider_list.html index 3b7d9fb..7e9d6a5 100644 --- a/gnuviechadmin/templates/socialaccount/snippets/provider_list.html +++ b/gnuviechadmin/templates/socialaccount/snippets/provider_list.html @@ -1,22 +1,24 @@ {% load socialaccount %} {% get_providers as socialaccount_providers %} -{% for provider in socialaccount_providers %} -{% if provider.id == "openid" %} -{% for brand in provider.get_brands %} -
  • - {{brand.name}} -
  • -{% endfor %} -{% endif %} -
  • -  {{provider.name}} -
  • -{% endfor %} - +