diff --git a/apps/authentication/templates/authentication/login.html b/apps/authentication/templates/authentication/login.html index bf0afa30b..521f3dbd2 100644 --- a/apps/authentication/templates/authentication/login.html +++ b/apps/authentication/templates/authentication/login.html @@ -57,7 +57,7 @@
- + {% trans 'Forgot password' %}?
@@ -90,5 +90,17 @@ $('#password-hidden').val(passwordEncrypted); //返回给密码输入input $('#form').submit();//post提交 } + + var authDB = '{{ AUTH_DB }}'; + var forgotPasswordUrl = "{% url 'authentication:forgot-password' %}"; + $(document).ready(function () { + }).on('click', '#forgot_password', function () { + if (authDB === 'True'){ + window.open(forgotPasswordUrl, "_blank") + } + else{ + alert("{% trans 'You are using another authentication server, please contact your administrator' %}") + } + }) {% endblock %} diff --git a/apps/authentication/templates/authentication/xpack_login.html b/apps/authentication/templates/authentication/xpack_login.html index a7a3773fc..d566ce1f8 100644 --- a/apps/authentication/templates/authentication/xpack_login.html +++ b/apps/authentication/templates/authentication/xpack_login.html @@ -131,7 +131,7 @@
- + {% trans 'Forgot password' %}?
@@ -144,6 +144,7 @@ + @@ -161,6 +162,18 @@ $('#password-hidden').val(passwordEncrypted); //返回给密码输入input $('#contact-form').submit();//post提交 } + + var authDB = '{{ AUTH_DB }}'; + var forgotPasswordUrl = "{% url 'authentication:forgot-password' %}"; + $(document).ready(function () { + }).on('click', '#forgot_password', function () { + if (authDB === 'True'){ + window.open(forgotPasswordUrl, "_blank") + } + else{ + alert("{% trans 'You are using another authentication server, please contact your administrator' %}") + } + }) diff --git a/apps/authentication/views/login.py b/apps/authentication/views/login.py index 100e190b6..42925b9ff 100644 --- a/apps/authentication/views/login.py +++ b/apps/authentication/views/login.py @@ -131,7 +131,8 @@ class UserLoginView(mixins.AuthMixin, FormView): context = { 'demo_mode': os.environ.get("DEMO_MODE"), 'AUTH_OPENID': settings.AUTH_OPENID, - 'rsa_public_key': rsa_public_key + 'rsa_public_key': rsa_public_key, + 'AUTH_DB': settings.AUTH_DB } kwargs.update(context) return super().get_context_data(**kwargs) diff --git a/apps/jumpserver/conf.py b/apps/jumpserver/conf.py index d5bff1819..57c5bed89 100644 --- a/apps/jumpserver/conf.py +++ b/apps/jumpserver/conf.py @@ -455,6 +455,9 @@ class DynamicConfig: backends.insert(0, 'authentication.backends.api.SSOAuthentication') return backends + def AUTH_DB(self): + return len(self.AUTHENTICATION_BACKENDS()) == 2 + def XPACK_LICENSE_IS_VALID(self): if not HAS_XPACK: return False diff --git a/apps/jumpserver/settings/auth.py b/apps/jumpserver/settings/auth.py index 4430aae2f..9f91cdb1d 100644 --- a/apps/jumpserver/settings/auth.py +++ b/apps/jumpserver/settings/auth.py @@ -9,6 +9,9 @@ from ..const import CONFIG, DYNAMIC, PROJECT_DIR OTP_ISSUER_NAME = CONFIG.OTP_ISSUER_NAME OTP_VALID_WINDOW = CONFIG.OTP_VALID_WINDOW +# Auth DB +AUTH_DB = DYNAMIC.AUTH_DB + # Auth LDAP settings AUTH_LDAP = DYNAMIC.AUTH_LDAP AUTH_LDAP_SERVER_URI = DYNAMIC.AUTH_LDAP_SERVER_URI