mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-01 04:56:45 +00:00
[SSO] Separate settings for local and social signup (#4171)
* [SSO] Separate settings for local and social signup Fixes #4166 * make registration setting configruable * extend docstring * add setting to settigns screen * update check ref * both settign most be checked
This commit is contained in:
parent
0ed2aa3a4d
commit
ac92471dcb
@ -210,8 +210,11 @@ class RegistratonMixin:
|
|||||||
"""Mixin to check if registration should be enabled."""
|
"""Mixin to check if registration should be enabled."""
|
||||||
|
|
||||||
def is_open_for_signup(self, request, *args, **kwargs):
|
def is_open_for_signup(self, request, *args, **kwargs):
|
||||||
"""Check if signup is enabled in settings."""
|
"""Check if signup is enabled in settings.
|
||||||
if settings.EMAIL_HOST and InvenTreeSetting.get_setting('LOGIN_ENABLE_REG', True):
|
|
||||||
|
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 super().is_open_for_signup(request, *args, **kwargs)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -1375,6 +1375,13 @@ class InvenTreeSetting(BaseInvenTreeSetting):
|
|||||||
'validator': bool,
|
'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': {
|
'LOGIN_MAIL_REQUIRED': {
|
||||||
'name': _('Email required'),
|
'name': _('Email required'),
|
||||||
'description': _('Require user to supply mail on signup'),
|
'description': _('Require user to supply mail on signup'),
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
<td colspan='4'></td>
|
<td colspan='4'></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% include "InvenTree/settings/setting.html" with key="LOGIN_ENABLE_REG" icon="fa-user-plus" %}
|
{% 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_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="LOGIN_SIGNUP_PWD_TWICE" icon="fa-user-lock" %}
|
||||||
{% include "InvenTree/settings/setting.html" with key="SIGNUP_GROUP" icon="fa-users" %}
|
{% include "InvenTree/settings/setting.html" with key="SIGNUP_GROUP" icon="fa-users" %}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% settings_value 'LOGIN_ENABLE_REG' as enable_reg %}
|
{% 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 %}
|
||||||
|
|
||||||
<h3>{% trans "Sign Up" %}</h3>
|
<h3>{% trans "Sign Up" %}</h3>
|
||||||
|
|
||||||
@ -21,17 +21,18 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
<button type="submit" class="btn btn-primary btn-block">{% trans "Sign Up" %}</button>
|
<button type="submit" class="btn btn-primary btn-block">{% trans "Sign Up" %}</button>
|
||||||
</form>
|
</form>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if enable_sso %}
|
{% if enable_sso %}
|
||||||
<br>
|
<br>
|
||||||
<h4>{% trans 'Or use a SSO-provider for signup' %}</h4>
|
<h4>{% trans 'Use a SSO-provider for signup' %}</h4>
|
||||||
<div>
|
<div>
|
||||||
{% include "socialaccount/snippets/provider_list.html" with process="login" %}
|
{% include "socialaccount/snippets/provider_list.html" with process="login" %}
|
||||||
</div>
|
</div>
|
||||||
{% include "socialaccount/snippets/login_extra.html" %}
|
{% include "socialaccount/snippets/login_extra.html" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% else %}
|
{% if not enable_reg and not enable_sso %}
|
||||||
<div class='alert alert-block alert-danger'>
|
<div class='alert alert-block alert-danger'>
|
||||||
<p>{% trans "This function is currently disabled. Please contact an administrator." %}</p>
|
<p>{% trans "This function is currently disabled. Please contact an administrator." %}</p>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user