perf(authentication): 修改用户登录页面,使用其他方式认证时点击忘记密码提示联系管理员

pull/4754/head
Bai 2020-09-30 11:37:11 +08:00 committed by 老广
parent 5dd1dfc59e
commit 6e91217303
5 changed files with 35 additions and 3 deletions

View File

@ -57,7 +57,7 @@
<div class="text-muted text-center"> <div class="text-muted text-center">
<div> <div>
<a href="{% url 'authentication:forgot-password' %}"> <a id="forgot_password" href="#">
<small>{% trans 'Forgot password' %}?</small> <small>{% trans 'Forgot password' %}?</small>
</a> </a>
</div> </div>
@ -90,5 +90,17 @@
$('#password-hidden').val(passwordEncrypted); //返回给密码输入input $('#password-hidden').val(passwordEncrypted); //返回给密码输入input
$('#form').submit();//post提交 $('#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' %}")
}
})
</script> </script>
{% endblock %} {% endblock %}

View File

@ -131,7 +131,7 @@
<button type="submit" class="btn btn-transparent" onclick="doLogin();return false;">{% trans 'Login' %}</button> <button type="submit" class="btn btn-transparent" onclick="doLogin();return false;">{% trans 'Login' %}</button>
</div> </div>
<div style="text-align: center"> <div style="text-align: center">
<a href="{% url 'authentication:forgot-password' %}"> <a id="forgot_password" href="#">
<small>{% trans 'Forgot password' %}?</small> <small>{% trans 'Forgot password' %}?</small>
</a> </a>
</div> </div>
@ -144,6 +144,7 @@
</div> </div>
</div> </div>
</div> </div>
</div>
</body> </body>
<script type="text/javascript" src="/static/js/plugins/jsencrypt/jsencrypt.min.js"></script> <script type="text/javascript" src="/static/js/plugins/jsencrypt/jsencrypt.min.js"></script>
@ -161,6 +162,18 @@
$('#password-hidden').val(passwordEncrypted); //返回给密码输入input $('#password-hidden').val(passwordEncrypted); //返回给密码输入input
$('#contact-form').submit();//post提交 $('#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' %}")
}
})
</script> </script>
</html> </html>

View File

@ -131,7 +131,8 @@ class UserLoginView(mixins.AuthMixin, FormView):
context = { context = {
'demo_mode': os.environ.get("DEMO_MODE"), 'demo_mode': os.environ.get("DEMO_MODE"),
'AUTH_OPENID': settings.AUTH_OPENID, '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) kwargs.update(context)
return super().get_context_data(**kwargs) return super().get_context_data(**kwargs)

View File

@ -455,6 +455,9 @@ class DynamicConfig:
backends.insert(0, 'authentication.backends.api.SSOAuthentication') backends.insert(0, 'authentication.backends.api.SSOAuthentication')
return backends return backends
def AUTH_DB(self):
return len(self.AUTHENTICATION_BACKENDS()) == 2
def XPACK_LICENSE_IS_VALID(self): def XPACK_LICENSE_IS_VALID(self):
if not HAS_XPACK: if not HAS_XPACK:
return False return False

View File

@ -9,6 +9,9 @@ from ..const import CONFIG, DYNAMIC, PROJECT_DIR
OTP_ISSUER_NAME = CONFIG.OTP_ISSUER_NAME OTP_ISSUER_NAME = CONFIG.OTP_ISSUER_NAME
OTP_VALID_WINDOW = CONFIG.OTP_VALID_WINDOW OTP_VALID_WINDOW = CONFIG.OTP_VALID_WINDOW
# Auth DB
AUTH_DB = DYNAMIC.AUTH_DB
# Auth LDAP settings # Auth LDAP settings
AUTH_LDAP = DYNAMIC.AUTH_LDAP AUTH_LDAP = DYNAMIC.AUTH_LDAP
AUTH_LDAP_SERVER_URI = DYNAMIC.AUTH_LDAP_SERVER_URI AUTH_LDAP_SERVER_URI = DYNAMIC.AUTH_LDAP_SERVER_URI