diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index 88377e0201..6d75186c95 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -834,6 +834,12 @@ class InvenTreeSetting(BaseInvenTreeSetting): 'default': True, 'validator': bool, }, + 'LOGIN_ENABLE_REG': { + 'name': _('Enable registration'), + 'description': _('Enable self-registration for users on the login-pages'), + 'default': False, + 'validator': bool, + }, } class Meta: diff --git a/InvenTree/templates/account/login.html b/InvenTree/templates/account/login.html index f5cc64717f..33bc15b526 100644 --- a/InvenTree/templates/account/login.html +++ b/InvenTree/templates/account/login.html @@ -6,10 +6,12 @@ {% block content %} +{% settings_value 'LOGIN_ENABLE_REG' as enable_reg %} {% settings_value 'LOGIN_ENABLE_PWD_FORGOT' as enable_pwd_forgot %}

{% trans "Sign In" %}

+{% if enable_reg %} {% get_providers as socialaccount_providers %} {% if socialaccount_providers %}

{% blocktrans with site.name as site_name %}Please sign in with one @@ -19,6 +21,7 @@ for a account and sign in below:{% endblocktrans %}

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

{% endif %} +{% endif %}
{% csrf_token %} diff --git a/InvenTree/templates/account/signup.html b/InvenTree/templates/account/signup.html index 6b68637374..c72a09502a 100644 --- a/InvenTree/templates/account/signup.html +++ b/InvenTree/templates/account/signup.html @@ -1,14 +1,17 @@ {% extends "account/base.html" %} -{% load i18n crispy_forms_tags %} +{% load i18n crispy_forms_tags inventree_extras %} {% block head_title %}{% trans "Signup" %}{% endblock %} {% block content %} +{% settings_value 'LOGIN_ENABLE_REG' as enable_reg %} +

{% trans "Sign Up" %}

{% blocktrans %}Already have an account? Then please sign in.{% endblocktrans %}

+{% if enable_reg %} {% csrf_token %} {{ form|crispy }} @@ -25,4 +28,10 @@ {% include "socialaccount/snippets/login_extra.html" %} +{% else %} +
+

{% trans "This function is currently disabled. Please contact an administrator." %}

+
+{% endif %} + {% endblock %}