Merge branch 'hotfix/gee-captcha-check' into release/5.5.1
Showing
11 changed files
with
33 additions
and
71 deletions
@@ -104,7 +104,10 @@ app.use(CookieSession({ // eslint-disable-line | @@ -104,7 +104,10 @@ app.use(CookieSession({ // eslint-disable-line | ||
104 | requestKey: 'session2', | 104 | requestKey: 'session2', |
105 | cookieName: 'yohobuy_session_cookie', | 105 | cookieName: 'yohobuy_session_cookie', |
106 | secret: '82dd7e724f2c6870472c89dfa43cf48d', | 106 | secret: '82dd7e724f2c6870472c89dfa43cf48d', |
107 | - domain: config.cookieDomain | 107 | + cookie: { |
108 | + domain: config.cookieDomain, | ||
109 | + ephemeral: true | ||
110 | + } | ||
108 | })); | 111 | })); |
109 | 112 | ||
110 | app.use((req, res, next) => { | 113 | app.use((req, res, next) => { |
@@ -110,7 +110,7 @@ const saveInSession = (req, res) => { | @@ -110,7 +110,7 @@ const saveInSession = (req, res) => { | ||
110 | case 'mobile': | 110 | case 'mobile': |
111 | req.session.mobile = req.inputInfo.phone; | 111 | req.session.mobile = req.inputInfo.phone; |
112 | req.session.area = req.inputInfo.area; | 112 | req.session.area = req.inputInfo.area; |
113 | - req.session.verifyCode = req.session.captcha; | 113 | + req.session.captcha = req.body.verifyCode; |
114 | res.redirect(helpers.urlFormat('/passport/back/verification')); | 114 | res.redirect(helpers.urlFormat('/passport/back/verification')); |
115 | break; | 115 | break; |
116 | default: | 116 | default: |
@@ -15,25 +15,7 @@ const CAPTCHA = config.UNIVERSAL_CAPTCHA; | @@ -15,25 +15,7 @@ const CAPTCHA = config.UNIVERSAL_CAPTCHA; | ||
15 | 15 | ||
16 | // 对比函数 | 16 | // 对比函数 |
17 | const _mustEqual = (req) => { | 17 | const _mustEqual = (req) => { |
18 | - let count = req.session.captchaCount; | ||
19 | - | ||
20 | - if (!req.session.captcha) { | ||
21 | - return false; | ||
22 | - } | ||
23 | - | ||
24 | - if (count >= 4) { | ||
25 | - req.session.captcha = CAPTCHA; | ||
26 | - return false; | ||
27 | - } | ||
28 | - | ||
29 | - req.session.captchaCount = count + 1; | ||
30 | - | ||
31 | - let result = req.body.verifyCode === req.session.captcha || | ||
32 | - req.body.verifyCode === CAPTCHA; | ||
33 | - | ||
34 | - logger.info(`geetest captcha auth [${result ? 'fail' : 'success'}]`, | ||
35 | - `CLIENT [${req.body.verifyCode}] SERVER [${req.session.captcha}]`); | ||
36 | - return result; | 18 | + return req.body.verifyCode === CAPTCHA; |
37 | }; | 19 | }; |
38 | 20 | ||
39 | var pcGeetest = new Geetest({ | 21 | var pcGeetest = new Geetest({ |
@@ -51,7 +33,6 @@ const generate = (req, res) => { | @@ -51,7 +33,6 @@ const generate = (req, res) => { | ||
51 | res.send(data); | 33 | res.send(data); |
52 | } else { | 34 | } else { |
53 | // 正常模式 | 35 | // 正常模式 |
54 | - req.session.captchaCount = 0; | ||
55 | res.send(data); | 36 | res.send(data); |
56 | } | 37 | } |
57 | }); | 38 | }); |
@@ -93,7 +74,6 @@ const requiredAPI = (req, res, next) => { | @@ -93,7 +74,6 @@ const requiredAPI = (req, res, next) => { | ||
93 | code: 401 | 74 | code: 401 |
94 | }); | 75 | }); |
95 | } else { | 76 | } else { |
96 | - req.session.captcha = verifyCode; | ||
97 | return next(); | 77 | return next(); |
98 | } | 78 | } |
99 | }); | 79 | }); |
@@ -184,6 +184,8 @@ let sendBindMsg = (req, res, next) => { | @@ -184,6 +184,8 @@ let sendBindMsg = (req, res, next) => { | ||
184 | /* 向手机发送注册验证码 */ | 184 | /* 向手机发送注册验证码 */ |
185 | let result = yield regService.sendCodeToMobile(area, mobile); | 185 | let result = yield regService.sendCodeToMobile(area, mobile); |
186 | 186 | ||
187 | + req.session.type = 'register-step1'; | ||
188 | + | ||
187 | return cache.set(sendCodeKey, sendCodeTimes + 1, 3600).then(() => { | 189 | return cache.set(sendCodeKey, sendCodeTimes + 1, 3600).then(() => { |
188 | if (result.code) { | 190 | if (result.code) { |
189 | return res.json(result); | 191 | return res.json(result); |
@@ -229,6 +231,10 @@ let mobileRegister = (req, res, next) => { | @@ -229,6 +231,10 @@ let mobileRegister = (req, res, next) => { | ||
229 | data: '' | 231 | data: '' |
230 | }; | 232 | }; |
231 | 233 | ||
234 | + if (req.session.type !== 'register-step1') { | ||
235 | + return res.json(data); | ||
236 | + } | ||
237 | + | ||
232 | /* 判断是否是有效的注册方式,防注册机刷 */ | 238 | /* 判断是否是有效的注册方式,防注册机刷 */ |
233 | let regExpireTime = req.session.REG_EXPIRE_; | 239 | let regExpireTime = req.session.REG_EXPIRE_; |
234 | 240 | ||
@@ -273,6 +279,9 @@ let mobileRegister = (req, res, next) => { | @@ -273,6 +279,9 @@ let mobileRegister = (req, res, next) => { | ||
273 | return res.json(data); | 279 | return res.json(data); |
274 | } | 280 | } |
275 | 281 | ||
282 | + // 清除 session type | ||
283 | + req.session.type = ''; | ||
284 | + | ||
276 | return loginService.syncUserSession(regResult.data.uid, req, res).then(() => { | 285 | return loginService.syncUserSession(regResult.data.uid, req, res).then(() => { |
277 | return res.json({ | 286 | return res.json({ |
278 | code: 200, | 287 | code: 200, |
@@ -107,7 +107,6 @@ router.post('/passport/reg/sendBindMsg', | @@ -107,7 +107,6 @@ router.post('/passport/reg/sendBindMsg', | ||
107 | reg.sendBindMsg); | 107 | reg.sendBindMsg); |
108 | 108 | ||
109 | router.post('/passport/reg/mobileregister', | 109 | router.post('/passport/reg/mobileregister', |
110 | - captcha.requiredAPI, | ||
111 | reg.checkMobileMiddleware, | 110 | reg.checkMobileMiddleware, |
112 | reg.checkPassword, | 111 | reg.checkPassword, |
113 | reg.mobileRegister); | 112 | reg.mobileRegister); |
@@ -31,7 +31,7 @@ | @@ -31,7 +31,7 @@ | ||
31 | </li> | 31 | </li> |
32 | <li class="input-container-li clearfix"> | 32 | <li class="input-container-li clearfix"> |
33 | <input name="refer" id="refer" type="hidden" value="http%3A%2F%2Fwww.yohobuy.com%2F"> | 33 | <input name="refer" id="refer" type="hidden" value="http%3A%2F%2Fwww.yohobuy.com%2F"> |
34 | - <input id="find-btn" class="btn find-btn disable" type="submit" value="下一步" disabled=""> | 34 | + <input id="find-btn" class="btn find-btn" type="submit" value="下一步" disabled=""> |
35 | </li> | 35 | </li> |
36 | </ul> | 36 | </ul> |
37 | </form> | 37 | </form> |
@@ -193,12 +193,10 @@ function checkAllForm() { | @@ -193,12 +193,10 @@ function checkAllForm() { | ||
193 | arr[key] = checkForm($(item)); | 193 | arr[key] = checkForm($(item)); |
194 | }); | 194 | }); |
195 | 195 | ||
196 | - if (captcha.$container.length !== 0) { | ||
197 | - captcha.check().then(function() { | ||
198 | - arr.push(true); | ||
199 | - }).fail(function() { | ||
200 | - arr.push(false); | ||
201 | - }); | 196 | + if (captcha.getResults() !== '') { |
197 | + arr.push(true); | ||
198 | + } else { | ||
199 | + arr.push(false); | ||
202 | } | 200 | } |
203 | 201 | ||
204 | if (arr.indexOf(false) >= 0) { | 202 | if (arr.indexOf(false) >= 0) { |
@@ -38,31 +38,6 @@ function enableBtn() { | @@ -38,31 +38,6 @@ function enableBtn() { | ||
38 | } | 38 | } |
39 | } | 39 | } |
40 | 40 | ||
41 | -function authcode() { | ||
42 | - return $.ajax({ | ||
43 | - type: 'POST', | ||
44 | - url: '/passport/back/authcode', | ||
45 | - data: { | ||
46 | - verifyCode: captcha.getResults(), | ||
47 | - phoneNum: $phoneNum.val(), | ||
48 | - area: $cr.val() | ||
49 | - } | ||
50 | - | ||
51 | - }).then(function(data) { | ||
52 | - if (data.code === 200) { | ||
53 | - $('#captcha-value').val(captcha.getResults()); | ||
54 | - return $.Deferred().resolve().promise(); //eslint-disable-line | ||
55 | - } else if (data.code === 402) { | ||
56 | - $accErr.removeClass('hide').find('em').text('该账号不存在'); | ||
57 | - $phoneNum.addClass('error'); | ||
58 | - return $.Deferred().reject().promise();//eslint-disable-line | ||
59 | - } else if (data.code === 400) { | ||
60 | - captcha.showTip(); | ||
61 | - return $.Deferred().reject().promise();//eslint-disable-line | ||
62 | - } | ||
63 | - }); | ||
64 | -} | ||
65 | - | ||
66 | function vaPn(v) { | 41 | function vaPn(v) { |
67 | var pass = true, | 42 | var pass = true, |
68 | errTxt = ''; | 43 | errTxt = ''; |
@@ -168,14 +143,10 @@ $('#find-btn').click(function(e) { | @@ -168,14 +143,10 @@ $('#find-btn').click(function(e) { | ||
168 | $('#find-form').attr('action', '/passport/back/mobile'); | 143 | $('#find-form').attr('action', '/passport/back/mobile'); |
169 | } | 144 | } |
170 | 145 | ||
171 | - if ($(this).hasClass('disable')) { | ||
172 | - return; | ||
173 | - } | 146 | + $('#captcha-value').val(captcha.getResults()); |
174 | 147 | ||
175 | if (hasPh) { | 148 | if (hasPh) { |
176 | - authcode().then(function() { | ||
177 | - $('#back-form').submit(); | ||
178 | - }); | 149 | + $('#back-form').submit(); |
179 | } | 150 | } |
180 | 151 | ||
181 | e.preventDefault(); | 152 | e.preventDefault(); |
@@ -160,13 +160,10 @@ function phoneAjaxFn(page, callback) { | @@ -160,13 +160,10 @@ function phoneAjaxFn(page, callback) { | ||
160 | 160 | ||
161 | // 图形验证码ajax校验 | 161 | // 图形验证码ajax校验 |
162 | function picCaptchaAjaxFn(callback) { | 162 | function picCaptchaAjaxFn(callback) { |
163 | - return captchaImage.check().then(function() { | ||
164 | - validateResult[1].message = ''; | ||
165 | - validateResult[1].status = true; | ||
166 | - }).fail(function() { | ||
167 | - validateResult[1].message = 'err'; | ||
168 | - validateResult[1].status = false; | ||
169 | - }).always(callback); | 163 | + validateResult[1].message = ''; |
164 | + validateResult[1].status = true; | ||
165 | + | ||
166 | + $.Deferred().resolve().promise().always(callback); // eslint-disable-line | ||
170 | } | 167 | } |
171 | 168 | ||
172 | // 短信验证码ajax校验 | 169 | // 短信验证码ajax校验 |
@@ -102,6 +102,10 @@ GeeCaptcha.prototype = { | @@ -102,6 +102,10 @@ GeeCaptcha.prototype = { | ||
102 | return $.Deferred().reject().promise(); // eslint-disable-line | 102 | return $.Deferred().reject().promise(); // eslint-disable-line |
103 | } | 103 | } |
104 | 104 | ||
105 | + if (!this.checkURI) { | ||
106 | + return $.Deferred().reject().promise(); // eslint-disable-line | ||
107 | + } | ||
108 | + | ||
105 | return $.post(this.checkURI, { | 109 | return $.post(this.checkURI, { |
106 | verifyCode: _this.getResults() | 110 | verifyCode: _this.getResults() |
107 | }).then(function(result) { | 111 | }).then(function(result) { |
-
Please register or login to post a comment