From 74f22274b4a3be7464259d7a1683aee2caa3c2e0 Mon Sep 17 00:00:00 2001 From: ibuler Date: Mon, 11 Nov 2019 10:58:11 +0800 Subject: [PATCH] =?UTF-8?q?[Update]=20=E4=BF=AE=E6=94=B9=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/authentication/login_wait_confirm.html | 10 ++++------ .../templates/authentication/xpack_login.html | 2 ++ apps/authentication/views/login.py | 5 +++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/apps/authentication/templates/authentication/login_wait_confirm.html b/apps/authentication/templates/authentication/login_wait_confirm.html index 845179db4..99841438e 100644 --- a/apps/authentication/templates/authentication/login_wait_confirm.html +++ b/apps/authentication/templates/authentication/login_wait_confirm.html @@ -81,7 +81,9 @@ function doRequestAuth() { url: url, method: "GET", success: function (data) { - if (data.error !== "login_confirm_wait") { + if (!data.error && data.msg === 'ok') { + window.location = "{% url 'authentication:login-guard' %}" + } else if (data.error !== "login_confirm_wait") { if (!errorMsgShow) { infoMsgRef.hide(); errorMsgRef.show(); @@ -90,11 +92,7 @@ function doRequestAuth() { } clearInterval(interval); clearInterval(checkInterval); - $(".copy-btn").attr('disabled', 'disabled') - } - if (data.msg === 'ok' && !data.error) { - window.location = "{% url 'authentication:login-guard' %}" - } else { + $(".copy-btn").attr('disabled', 'disabled'); errorMsgRef.html(data.msg) } }, diff --git a/apps/authentication/templates/authentication/xpack_login.html b/apps/authentication/templates/authentication/xpack_login.html index 2035cc360..ba3f92308 100644 --- a/apps/authentication/templates/authentication/xpack_login.html +++ b/apps/authentication/templates/authentication/xpack_login.html @@ -85,6 +85,8 @@ {% elif form.errors.captcha %}

{% trans 'Captcha invalid' %}

+ {% else %} +
{% endif %}
diff --git a/apps/authentication/views/login.py b/apps/authentication/views/login.py index 6dd3355c0..94226a237 100644 --- a/apps/authentication/views/login.py +++ b/apps/authentication/views/login.py @@ -22,7 +22,6 @@ from common.utils import get_request_ip, get_object_or_none from users.utils import ( redirect_user_first_login_or_index ) -from ..signals import post_auth_success, post_auth_failed from .. import forms, mixins, errors @@ -75,7 +74,9 @@ class UserLoginView(mixins.AuthMixin, FormView): form.add_error(None, e.msg) ip = self.get_request_ip() cache.set(self.key_prefix_captcha.format(ip), 1, 3600) - context = self.get_context_data(form=form) + new_form = self.form_class_captcha(data=form.data) + new_form._errors = form.errors + context = self.get_context_data(form=new_form) return self.render_to_response(context) return self.redirect_to_guard_view()