Commit b7deffdf authored by Michal Čihař's avatar Michal Čihař

Do not offer password reset without email auth

We're using email authentication backend to send the password reset
link, without it there is no way to do this.
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 2323908f
......@@ -389,6 +389,7 @@ def weblate_login(request):
'login_backends': [
x for x in auth_backends if x != 'email'
],
'can_reset': 'email' in auth_backends,
'title': _('Login'),
}
)
......@@ -530,6 +531,13 @@ def reset_password(request):
'''
Password reset handling.
'''
if 'email' not in load_backends(BACKENDS).keys():
messages.error(
request,
_('Can not reset password, email authentication is disabled!')
)
return redirect('login')
if request.method == 'POST':
form = ResetForm(request.POST)
if form.is_valid():
......
......@@ -30,8 +30,10 @@
{% csrf_token %}
{{ form|crispy }}
<p class="helptext">
{% if can_reset %}
{% url 'password_reset' as reset_url %}
{% blocktrans %}Forgot your password? You can <a href="{{ reset_url }}">reset it</a>.{% endblocktrans %}
{% endif %}
</p>
<input type="hidden" name="next" value="{{ next }}" />
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment