From 5790dbe2fb7c6f2d084c93b5eaeb97aa526427d5 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Mon, 18 Mar 2019 09:25:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9BUG=EF=BC=9A=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E9=A1=B5=E9=9D=A2=E5=BF=98=E8=AE=B0=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=A2=9E=E5=8A=A0=E8=A1=8C=E4=B8=BA=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E7=A0=81=20closed=20#ITOIA=20closed=20#ITOIB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #Issue https://gitee.com/LongbowEnterprise/dashboard/issues?id=ITOIA https://gitee.com/LongbowEnterprise/dashboard/issues?id=ITOIB --- Bootstrap.Admin/Views/Account/Login.cshtml | 16 +++- .../wwwroot/css/login-responsive.css | 3 + Bootstrap.Admin/wwwroot/css/login.css | 14 +++ Bootstrap.Admin/wwwroot/js/login.js | 88 ++++++++++++------- .../lib/captcha/longbow.slidercaptcha.js | 6 +- 5 files changed, 91 insertions(+), 36 deletions(-) diff --git a/Bootstrap.Admin/Views/Account/Login.cshtml b/Bootstrap.Admin/Views/Account/Login.cshtml index 86fe8af3..f4000a6f 100644 --- a/Bootstrap.Admin/Views/Account/Login.cshtml +++ b/Bootstrap.Admin/Views/Account/Login.cshtml @@ -112,7 +112,7 @@ - +
@@ -151,6 +151,13 @@ 提交 +
+
+ 请完成安全验证 + +
+
+
@@ -199,6 +206,13 @@ 提交 +
+
+ 请完成安全验证 + +
+
+
diff --git a/Bootstrap.Admin/wwwroot/css/login-responsive.css b/Bootstrap.Admin/wwwroot/css/login-responsive.css index 276c053e..2270eb48 100644 --- a/Bootstrap.Admin/wwwroot/css/login-responsive.css +++ b/Bootstrap.Admin/wwwroot/css/login-responsive.css @@ -38,6 +38,9 @@ .slidercaptcha { top: -254px; left: -15px; + } + + .slidercaptcha, .slidercaptcha.forgot { width: 310px; height: 280px; } diff --git a/Bootstrap.Admin/wwwroot/css/login.css b/Bootstrap.Admin/wwwroot/css/login.css index c5c37f3c..28328ef2 100644 --- a/Bootstrap.Admin/wwwroot/css/login.css +++ b/Bootstrap.Admin/wwwroot/css/login.css @@ -86,3 +86,17 @@ .slidercaptcha.card .card-header .close:hover { color: #fff; } + +.slidercaptcha.forgot { + position: absolute; + left: auto; + right: 14px; + bottom: 14px; + top: auto; + margin: 0; + width: 274px; +} + +.slidercaptcha.reg { + bottom: 60px; +} \ No newline at end of file diff --git a/Bootstrap.Admin/wwwroot/js/login.js b/Bootstrap.Admin/wwwroot/js/login.js index aae019de..784b663e 100644 --- a/Bootstrap.Admin/wwwroot/js/login.js +++ b/Bootstrap.Admin/wwwroot/js/login.js @@ -13,43 +13,57 @@ } }); - $.extend({ - captchaCheck: function (success) { + $.extend({ + captchaCheck: function (captcha, success) { $.bc({ url: "api/OnlineUsers", method: "put", callback: function (result) { - if (result) $captcha.addClass('d-block'); + if (result) captcha.addClass('d-block'); else success(); } - }); + }); + }, + capWidth: function () { + return $(window).width() < 768 ? 216 : 280; + }, + capHeight: function () { + return $(window).width() < 768 ? 110 : 150; + }, + capRegSuccess: function () { + $.bc({ + url: "api/Register", + data: { UserName: $('#userName').val(), Password: $('#password').val(), DisplayName: $('#displayName').val(), Description: $('#description').val() }, + modal: '#dialogNew', + method: "post", + callback: function (result) { + var title = result ? "提交成功
等待管理员审批" : "提交失败"; + lgbSwal({ timer: 1500, title: title, type: result ? "success" : "error" }); + } + }); + }, + capForgotSuccess: function () { + $.bc({ + url: "api/Register", + data: { UserName: $('#f_userName').val(), DisplayName: $('#f_displayName').val(), Reason: $('#f_desc').val() }, + modal: '#dialogForgot', + method: "put", + callback: function (result) { + var title = result ? "提交成功
等待管理员重置密码" : "提交失败"; + lgbSwal({ timer: 1500, title: title, type: result ? "success" : "error" }); + } + }); } }); $('#btnSubmit').on('click', function () { - $.bc({ - url: "api/Register", - data: { UserName: $('#userName').val(), Password: $('#password').val(), DisplayName: $('#displayName').val(), Description: $('#description').val() }, - modal: '#dialogNew', - method: "post", - callback: function (result) { - var title = result ? "提交成功
等待管理员审批" : "提交失败"; - lgbSwal({ timer: 1500, title: title, type: result ? "success" : "error" }); - } - }); + $.captchaCheck($('#dialogNew .slidercaptcha'), $.capRegSuccess); + return false; }); $('#btnForgot').on('click', function () { - $.bc({ - url: "api/Register", - data: { UserName: $('#f_userName').val(), DisplayName: $('#f_displayName').val(), Reason: $('#f_desc').val() }, - modal: '#dialogForgot', - method: "put", - callback: function (result) { - var title = result ? "提交成功
等待管理员重置密码" : "提交失败"; - lgbSwal({ timer: 1500, title: title, type: result ? "success" : "error" }); - } - }); + $.captchaCheck($('#dialogForgot .slidercaptcha'), $.capForgotSuccess); + return false; }); $('.rememberPwd').on('click', function () { @@ -65,26 +79,36 @@ } }); - var $captcha = $('.slidercaptcha'); - $('.slidercaptcha .close').on('click', function () { - $captcha.removeClass('d-block'); + $('.slidercaptcha .close').on('click', function (e) { + $(this).parents('.slidercaptcha').removeClass('d-block'); + return false; }); $('button[type="submit"]').on('click', function (e) { - $.captchaCheck(function () { + $.captchaCheck($('#login .slidercaptcha'), function () { $('form').submit(); }); return false; }); - $('#captcha').sliderCaptcha({ - width: $(window).width() < 768 ? 216 : 280, - height: $(window).width() < 768 ? 110 : 150, + $('#captcha, #regcap, #forgotcap').sliderCaptcha({ + width: $.capWidth(), + height: $.capHeight(), setSrc: function () { return 'http://pocoafrro.bkt.clouddn.com/Pic' + Math.round(Math.random() * 136) + '.jpg'; }, onSuccess: function () { - $('form').submit(); + var parent = this.$element.parents('.slidercaptcha').removeClass('d-block'); + this.reset(); + if (parent.hasClass('reg')) { + $.capRegSuccess(); + } + else if (parent.hasClass('forgot')) { + $.capForgotSuccess(); + } + else { + $('form').submit(); + } } }); }); \ No newline at end of file diff --git a/Bootstrap.Admin/wwwroot/lib/captcha/longbow.slidercaptcha.js b/Bootstrap.Admin/wwwroot/lib/captcha/longbow.slidercaptcha.js index 43af4bba..107295a2 100644 --- a/Bootstrap.Admin/wwwroot/lib/captcha/longbow.slidercaptcha.js +++ b/Bootstrap.Admin/wwwroot/lib/captcha/longbow.slidercaptcha.js @@ -185,7 +185,7 @@ $(this.refreshIcon).on('click', function () { that.text.text(that.options.barText); that.reset(); - if ($.isFunction(that.options.onRefresh)) that.options.onRefresh.call(that.$element); + if ($.isFunction(that.options.onRefresh)) that.options.onRefresh.call(that); }); var originX, originY, trail = [], @@ -226,10 +226,10 @@ } = that.verify() if (spliced && verified) { that.sliderContainer.addClass('sliderContainer_success'); - if ($.isFunction(that.options.onSuccess)) that.options.onSuccess.call(that.$element); + if ($.isFunction(that.options.onSuccess)) that.options.onSuccess.call(that); } else { that.sliderContainer.addClass('sliderContainer_fail'); - if ($.isFunction(that.options.onFail)) that.options.onFail.call(that.$element); + if ($.isFunction(that.options.onFail)) that.options.onFail.call(that); setTimeout(() => { that.text.text(that.options.failedText); that.reset();