diff --git a/InvenTree/InvenTree/forms.py b/InvenTree/InvenTree/forms.py index 2a65cc2e1d..7078448d56 100644 --- a/InvenTree/InvenTree/forms.py +++ b/InvenTree/InvenTree/forms.py @@ -210,8 +210,11 @@ class RegistratonMixin: """Mixin to check if registration should be enabled.""" def is_open_for_signup(self, request, *args, **kwargs): - """Check if signup is enabled in settings.""" - if settings.EMAIL_HOST and InvenTreeSetting.get_setting('LOGIN_ENABLE_REG', True): + """Check if signup is enabled in settings. + + Configure the class variable `REGISTRATION_SETTING` to set which setting should be used, defualt: `LOGIN_ENABLE_REG`. + """ + if settings.EMAIL_HOST and (InvenTreeSetting.get_setting('LOGIN_ENABLE_REG') or InvenTreeSetting.get_setting('LOGIN_ENABLE_SSO_REG')): return super().is_open_for_signup(request, *args, **kwargs) return False diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index fa77c35522..28b8322727 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -1375,6 +1375,13 @@ class InvenTreeSetting(BaseInvenTreeSetting): 'validator': bool, }, + 'LOGIN_ENABLE_SSO_REG': { + 'name': _('Enable SSO registration'), + 'description': _('Enable self-registration via SSO for users on the login pages'), + 'default': False, + 'validator': bool, + }, + 'LOGIN_MAIL_REQUIRED': { 'name': _('Email required'), 'description': _('Require user to supply mail on signup'), diff --git a/InvenTree/templates/InvenTree/settings/login.html b/InvenTree/templates/InvenTree/settings/login.html index d9b11eb692..9710a9eec5 100644 --- a/InvenTree/templates/InvenTree/settings/login.html +++ b/InvenTree/templates/InvenTree/settings/login.html @@ -27,6 +27,7 @@ {% include "InvenTree/settings/setting.html" with key="LOGIN_ENABLE_REG" icon="fa-user-plus" %} + {% include "InvenTree/settings/setting.html" with key="LOGIN_ENABLE_SSO_REG" icon="fa-user-plus" %} {% include "InvenTree/settings/setting.html" with key="LOGIN_SIGNUP_MAIL_TWICE" icon="fa-at" %} {% include "InvenTree/settings/setting.html" with key="LOGIN_SIGNUP_PWD_TWICE" icon="fa-user-lock" %} {% include "InvenTree/settings/setting.html" with key="SIGNUP_GROUP" icon="fa-users" %} diff --git a/InvenTree/templates/account/signup.html b/InvenTree/templates/account/signup.html index 3e1aa18918..07aac91cab 100644 --- a/InvenTree/templates/account/signup.html +++ b/InvenTree/templates/account/signup.html @@ -6,7 +6,7 @@ {% block content %} {% settings_value 'LOGIN_ENABLE_REG' as enable_reg %} -{% settings_value 'LOGIN_ENABLE_SSO' as enable_sso %} +{% settings_value 'LOGIN_ENABLE_SSO_REG' as enable_sso %}

{% trans "Sign Up" %}

@@ -21,17 +21,18 @@ {% endif %} +{% endif %} {% if enable_sso %}
-

{% trans 'Or use a SSO-provider for signup' %}

+

{% trans 'Use a SSO-provider for signup' %}

{% include "socialaccount/snippets/provider_list.html" with process="login" %}
{% include "socialaccount/snippets/login_extra.html" %} {% endif %} -{% else %} +{% if not enable_reg and not enable_sso %}

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