Showing
3 changed files
with
14 additions
and
6 deletions
@@ -29,14 +29,18 @@ const checkAPI = (req, res) => { | @@ -29,14 +29,18 @@ const checkAPI = (req, res) => { | ||
29 | }; | 29 | }; |
30 | 30 | ||
31 | const passwordRequired = (req, res, next) => { | 31 | const passwordRequired = (req, res, next) => { |
32 | - | ||
33 | // 默认账户密码登录需要验证码 | 32 | // 默认账户密码登录需要验证码 |
34 | - // if (req.session.type === 'needCaptcha' && req.body.loginType === 'password') { | ||
35 | - if (req.body.loginType === 'password') { | ||
36 | - return requiredAPI(req, res, next); | 33 | + if (_.get(req.app.pc, 'password.alwaysNeedCaptcha', false)) { |
34 | + if (req.body.loginType === 'password') { | ||
35 | + return requiredAPI(req, res, next); | ||
36 | + } | ||
37 | } else { | 37 | } else { |
38 | - return next(); | 38 | + if (req.session.type === 'needCaptcha' && req.body.loginType === 'password') { |
39 | + return requiredAPI(req, res, next); | ||
40 | + } | ||
39 | } | 41 | } |
42 | + | ||
43 | + return next(); | ||
40 | }; | 44 | }; |
41 | 45 | ||
42 | const tryGeetest = (req, res, next) => { | 46 | const tryGeetest = (req, res, next) => { |
@@ -2,3 +2,7 @@ | @@ -2,3 +2,7 @@ | ||
2 | <script>window._geeCaptcha = true;</script> | 2 | <script>window._geeCaptcha = true;</script> |
3 | <script src="https://static.geetest.com/static/tools/gt.js"></script> | 3 | <script src="https://static.geetest.com/static/tools/gt.js"></script> |
4 | {{/if}} | 4 | {{/if}} |
5 | + | ||
6 | +{{#if @root.pc.password.alwaysNeedCaptcha}} | ||
7 | + <script>window._passwordCaptcha = true;</script> | ||
8 | +{{/if}} |
@@ -56,7 +56,7 @@ var $accountInput1 = $('#account1'), | @@ -56,7 +56,7 @@ var $accountInput1 = $('#account1'), | ||
56 | // 图像验证码 | 56 | // 图像验证码 |
57 | $passwordCaptchaWrap = $('.captcha-wrap'), | 57 | $passwordCaptchaWrap = $('.captcha-wrap'), |
58 | passwordCaptchaImg = new Captcha('.captcha-wrap', {checkURI: ''}).init(), | 58 | passwordCaptchaImg = new Captcha('.captcha-wrap', {checkURI: ''}).init(), |
59 | - isShowCaptchaImg = true, | 59 | + isShowCaptchaImg = window._passwordCaptcha || false, |
60 | getPasswordCaptchaImgVal = function() { | 60 | getPasswordCaptchaImgVal = function() { |
61 | if (isShowCaptchaImg) { | 61 | if (isShowCaptchaImg) { |
62 | return passwordCaptchaImg.getResults(); | 62 | return passwordCaptchaImg.getResults(); |
-
Please register or login to post a comment