From 46a8a9f60d61cc364d378875ae9f1fe771965c02 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Fri, 28 May 2021 18:41:30 +0200 Subject: [PATCH] disable password reset if no mail is set --- cookbook/helper/AllAuthCustomAdapter.py | 2 +- cookbook/templates/account/login.html | 6 ++++- .../templates/account/password_reset.html | 26 ++++++++++++------- .../account/password_reset_done.html | 2 +- cookbook/templates/account/signup_closed.html | 7 +++-- 5 files changed, 26 insertions(+), 17 deletions(-) diff --git a/cookbook/helper/AllAuthCustomAdapter.py b/cookbook/helper/AllAuthCustomAdapter.py index 47629283c..1823265f0 100644 --- a/cookbook/helper/AllAuthCustomAdapter.py +++ b/cookbook/helper/AllAuthCustomAdapter.py @@ -16,7 +16,7 @@ class AllAuthCustomAdapter(DefaultAccountAdapter): # disable password reset for now def send_mail(self, template_prefix, email, context): - if settings.EMAIL_HOST == '': + if settings.EMAIL_HOST != '': super(AllAuthCustomAdapter, self).send_mail(template_prefix, email, context) else: pass diff --git a/cookbook/templates/account/login.html b/cookbook/templates/account/login.html index 64ecfdd15..6034a76f4 100644 --- a/cookbook/templates/account/login.html +++ b/cookbook/templates/account/login.html @@ -27,7 +27,11 @@ {% trans "Sign Up" %} - {% trans "Reset Password" %} + + {% if settings.EMAIL_HOST != '' %} + {% trans "Reset Password" %} + {% endif %} diff --git a/cookbook/templates/account/password_reset.html b/cookbook/templates/account/password_reset.html index 514a5aeef..3db14cd31 100644 --- a/cookbook/templates/account/password_reset.html +++ b/cookbook/templates/account/password_reset.html @@ -4,23 +4,29 @@ {% load i18n %} {% load account %} -{% block head_title %}{% trans "Password Reset" %}{% endblock %} +{% block title %}{% trans 'Password Reset' %}{% endblock %} {% block content %}

{% trans "Password Reset" %}

{% if user.is_authenticated %} - {% include "account/snippets/already_logged_in.html" %} + {% include "account/snippets/already_logged_in.html" %} + {% endif %} + + {% if settings.EMAIL_HOST != '' %} +

{% trans "Forgotten your password? Enter your e-mail address below, and we'll send you an e-mail allowing you to reset it." %}

+ +
+ {% csrf_token %} + {{ form | crispy }} + + {% trans "Sign In" %} + {% trans "Sign Up" %} +
+ {% else %} +

{% trans 'Password reset is disabled on this instance.' %}

{% endif %} -

{% trans "Forgotten your password? Enter your e-mail address below, and we'll send you an e-mail allowing you to reset it." %}

-
- {% csrf_token %} - {{ form | crispy}} - - {% trans "Sign In" %} - {% trans "Sign Up" %} -
{% endblock %} \ No newline at end of file diff --git a/cookbook/templates/account/password_reset_done.html b/cookbook/templates/account/password_reset_done.html index 244d45044..b756e8abc 100644 --- a/cookbook/templates/account/password_reset_done.html +++ b/cookbook/templates/account/password_reset_done.html @@ -4,7 +4,7 @@ {% load i18n %} {% load account %} -{% block head_title %}{% trans "Password Reset" %}{% endblock %} +{% block title %}{% trans "Password Reset" %}{% endblock %} {% block content %}

{% trans "Password Reset" %}

diff --git a/cookbook/templates/account/signup_closed.html b/cookbook/templates/account/signup_closed.html index 2f48ea4d6..355d5a44b 100644 --- a/cookbook/templates/account/signup_closed.html +++ b/cookbook/templates/account/signup_closed.html @@ -2,13 +2,12 @@ {% load i18n %} -{% block head_title %}{% trans "Sign Up Closed" %}{% endblock %} +{% block title %}{% trans "Sign Up Closed" %}{% endblock %} {% block content %} -

{% trans "Sign Up Closed" %}

+

{% trans "Sign Up Closed" %}

-

{% trans "We are sorry, but the sign up is currently closed." %}

+

{% trans "We are sorry, but the sign up is currently closed." %}

{% trans "Sign In" %} - {% trans "Reset Password" %} {% endblock %} \ No newline at end of file