mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Remove "forgot password" link if the email backend is not configured
This commit is contained in:
parent
f902b79d79
commit
96efb0eb28
@ -32,6 +32,7 @@ def health_status(request):
|
||||
|
||||
status = {
|
||||
'django_q_running': InvenTree.status.is_worker_running(),
|
||||
'email_configured': InvenTree.status.is_email_configured(),
|
||||
}
|
||||
|
||||
all_healthy = True
|
||||
|
@ -498,7 +498,10 @@ EXCHANGE_BACKEND = 'InvenTree.exchange.InvenTreeManualExchangeBackend'
|
||||
# Extract email settings from the config file
|
||||
email_config = CONFIG.get('email', {})
|
||||
|
||||
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
|
||||
EMAIL_BACKEND = get_setting(
|
||||
'django.core.mail.backends.smtp.EmailBackend',
|
||||
email_config.get('backend', '')
|
||||
)
|
||||
|
||||
# Email backend settings
|
||||
EMAIL_HOST = get_setting(
|
||||
|
@ -11,6 +11,9 @@ from datetime import datetime, timedelta
|
||||
from django_q.models import Success
|
||||
from django_q.monitor import Stat
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
logger = logging.getLogger("inventree")
|
||||
|
||||
|
||||
@ -43,6 +46,30 @@ def is_worker_running(**kwargs):
|
||||
return results.exists()
|
||||
|
||||
|
||||
def is_email_configured():
|
||||
"""
|
||||
Check if email backend is configured.
|
||||
|
||||
NOTE: This does not check if the configuration is valid!
|
||||
"""
|
||||
|
||||
configured = True
|
||||
|
||||
if not settings.EMAIL_HOST:
|
||||
logger.warning("EMAIL_HOST is not configured")
|
||||
configured = False
|
||||
|
||||
if not settings.EMAIL_HOST_USER:
|
||||
logger.warning("EMAIL_HOST_USER is not configured")
|
||||
configured = False
|
||||
|
||||
if not settings.EMAIL_HOST_PASSWORD:
|
||||
logger.warning("EMAIL_HOST_PASSWORD is not configured")
|
||||
configured = False
|
||||
|
||||
return configured
|
||||
|
||||
|
||||
def check_system_health(**kwargs):
|
||||
"""
|
||||
Check that the InvenTree system is running OK.
|
||||
@ -56,6 +83,10 @@ def check_system_health(**kwargs):
|
||||
result = False
|
||||
logger.warning(_("Background worker check failed"))
|
||||
|
||||
if not is_email_configured():
|
||||
result = False
|
||||
logger.warning(_("Email backend not configured"))
|
||||
|
||||
if not result:
|
||||
logger.warning(_("InvenTree system health checks failed"))
|
||||
|
||||
|
@ -74,7 +74,9 @@ currencies:
|
||||
# tls: Enable TLS support
|
||||
# ssl: Enable SSL support
|
||||
|
||||
# Alternatively, these options can all be set using environment variables
|
||||
# Alternatively, these options can all be set using environment variables,
|
||||
# with the INVENTREE_EMAIL_ prefix:
|
||||
# e.g. INVENTREE_EMAIL_HOST / INVENTREE_EMAIL_PORT / INVENTREE_EMAIL_USERNAME
|
||||
# Refer to the InvenTree documentation for more information
|
||||
|
||||
email:
|
||||
|
@ -89,9 +89,12 @@
|
||||
<button class='pull-right btn btn-primary login-button' type="submit">{% trans "Login" %}</button>
|
||||
|
||||
</form>
|
||||
|
||||
{% if email_configured %}
|
||||
<hr><br>
|
||||
<p>{% trans "Forgotten your password?" %} - <a href='{% url "password_reset" %}'>{% trans "Click here to reset" %}</a></p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -25,18 +25,29 @@
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% if not django_q_running %}
|
||||
<tr>
|
||||
<td><span class='fas fa-tasks'></span></td>
|
||||
<td>{% trans "Background Worker" %}</td>
|
||||
<td>
|
||||
{% if django_q_running %}
|
||||
<span class='label label-green'>{% trans "Operational" %}</span>
|
||||
{% else %}
|
||||
<span class='label label-red'>{% trans "Not running" %}</span>
|
||||
{% endif %}
|
||||
<a href='https://inventree.readthedocs.io/en/latest/admin/tasks'>
|
||||
<span class='label label-red'>{% trans "Background worker not running" %}</span>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if not email_configured %}
|
||||
<tr>
|
||||
<td><span class='fas fa-envelope'></span></td>
|
||||
<td>{% trans "Email Settings" %}</td>
|
||||
<td>
|
||||
<a href='https://inventree.readthedocs.io/en/latest/admin/email'>
|
||||
<span class='label label-red'>{% trans "Email settings not configured" %}</span>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if not system_healthy %}
|
||||
{% for issue in system_issues %}
|
||||
|
Loading…
Reference in New Issue
Block a user