setting for pwd forgot

This commit is contained in:
Matthias 2021-09-05 19:56:48 +02:00
parent 1146e2abd9
commit fa1ea2f701
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076
5 changed files with 31 additions and 4 deletions

View File

@ -826,6 +826,14 @@ class InvenTreeSetting(BaseInvenTreeSetting):
'default': True,
'validator': bool,
},
# login / SSO
'LOGIN_ENABLE_PWD_FORGOT': {
'name': _('Enable password forgot'),
'description': _('Enable password forgot function on the login-pages'),
'default': True,
'validator': bool,
},
}
class Meta:

View File

@ -14,7 +14,9 @@
<table class='table table-striped table-condensed'>
{% include "InvenTree/settings/header.html" %}
<tbody>
{% include "InvenTree/settings/setting.html" with key="LOGIN_ENABLE_REG" icon="fa-info-circle" %}
{% include "InvenTree/settings/setting.html" with key="LOGIN_ENABLE_SSO" icon="fa-info-circle" %}
{% include "InvenTree/settings/setting.html" with key="LOGIN_ENABLE_PWD_FORGOT" icon="fa-info-circle" %}
</tbody>
</table>

View File

@ -1,11 +1,13 @@
{% extends "account/base.html" %}
{% load i18n account socialaccount crispy_forms_tags %}
{% load i18n account socialaccount crispy_forms_tags inventree_extras %}
{% block head_title %}{% trans "Sign In" %}{% endblock %}
{% block content %}
{% settings_value 'LOGIN_ENABLE_PWD_FORGOT' as enable_pwd_forgot %}
<h1>{% trans "Sign In" %}</h1>
{% get_providers as socialaccount_providers %}
@ -27,7 +29,9 @@ for a account and sign in below:{% endblocktrans %}</p>
<div class="btn-toolbar">
<button class="btn btn-primary col-md-8" type="submit">{% trans "Sign In" %}</button>
{% if enable_pwd_forgot %}
<a class="btn btn-primary" href="{% url 'account_reset_password' %}">{% trans "Forgot Password?" %}</a>
{% endif %}
</div>
</form>

View File

@ -1,16 +1,21 @@
{% extends "account/base.html" %}
{% load i18n crispy_forms_tags %}
{% load i18n crispy_forms_tags inventree_extras %}
{% block head_title %}{% trans "Change Password" %}{% endblock %}
{% block content %}
{% settings_value 'LOGIN_ENABLE_PWD_FORGOT' as enable_pwd_forgot %}
<h1>{% trans "Change Password" %}</h1>
<form method="POST" action="{% url 'account_change_password' %}" class="password_change">
{% csrf_token %}
{{ form|crispy }}
<button type="submit" class="btn btn-primary" name="action">{% trans "Change Password" %}</button>
{% if enable_pwd_forgot %}
<a href="{% url 'account_reset_password' %}">{% trans "Forgot Password?" %}</a>
{% endif %}
</form>
{% endblock %}

View File

@ -1,16 +1,19 @@
{% extends "account/base.html" %}
{% load i18n account crispy_forms_tags %}
{% load i18n account crispy_forms_tags inventree_extras %}
{% block head_title %}{% trans "Password Reset" %}{% endblock %}
{% block content %}
{% settings_value 'LOGIN_ENABLE_PWD_FORGOT' as enable_pwd_forgot %}
<h1>{% trans "Password Reset" %}</h1>
{% if user.is_authenticated %}
{% include "account/snippets/already_logged_in.html" %}
{% endif %}
{% if enable_pwd_forgot %}
<p>{% trans "Forgotten your password? Enter your e-mail address below, and we'll send you an e-mail allowing you to reset it." %}</p>
<form method="POST" action="{% url 'account_reset_password' %}" class="password_reset">
@ -18,4 +21,9 @@
{{ form|crispy }}
<input type="submit" class="btn btn-primary btn-block" value="{% trans 'Reset My Password' %}" />
</form>
{% else %}
<div class='alert alert-block alert-danger'>
<p>{% trans "This function is currently disabled. Please contact an administrator." %}</p>
</div>
{% endif %}
{% endblock %}