Authored by ccbikai(👎🏻🍜)

每次都校验验证码

@@ -211,7 +211,7 @@ const sendCodeToMobileAPI = (req, res, next) => { @@ -211,7 +211,7 @@ const sendCodeToMobileAPI = (req, res, next) => {
211 if (verifyCode) { 211 if (verifyCode) {
212 let captcha = _.get(req, 'session.captcha'); 212 let captcha = _.get(req, 'session.captcha');
213 213
214 - logger.info(`验证码校验结果${verifyCode.toString() === captcha},user:${verifyCode};server:${captcha}`); 214 + logger.info(`captcha validate result${verifyCode.toString() === captcha},user:${verifyCode};server:${captcha}`);
215 if ((captcha && verifyCode.toString() === captcha) || (testCode === config.testCode)) { 215 if ((captcha && verifyCode.toString() === captcha) || (testCode === config.testCode)) {
216 req.session.backupCaptch.verifyResult = true; 216 req.session.backupCaptch.verifyResult = true;
217 } else { 217 } else {
@@ -97,7 +97,7 @@ const bind = { @@ -97,7 +97,7 @@ const bind = {
97 if (verify) { 97 if (verify) {
98 let captcha = _.get(req, 'session.captcha'); 98 let captcha = _.get(req, 'session.captcha');
99 99
100 - logger.info(`验证码校验结果${verify.toString() === captcha},user:${verify};server:${captcha}`); 100 + logger.info(`captcha validate result${verify.toString() === captcha},user:${verify};server:${captcha}`);
101 if ((captcha && verify.toString() === captcha) || (testCode === config.testCode)) { 101 if ((captcha && verify.toString() === captcha) || (testCode === config.testCode)) {
102 BindService.bindCheck(phoneNum, openId, sourceType, areaCode).then(result => { 102 BindService.bindCheck(phoneNum, openId, sourceType, areaCode).then(result => {
103 let data = { 103 let data = {
@@ -113,11 +113,7 @@ const local = { @@ -113,11 +113,7 @@ const local = {
113 width750: true, 113 width750: true,
114 loginIndex: true, // 模板中使用JS的标识 114 loginIndex: true, // 模板中使用JS的标识
115 useGeetest: _.get(req.app.locals.wap, 'geetest.validation', true), // 使用极验证 115 useGeetest: _.get(req.app.locals.wap, 'geetest.validation', true), // 使用极验证
116 -  
117 - // captchaShow: _.get(req.session, 'login.errorCount') <= 0,  
118 captchaShow: true, // 170306 因为暴力破解密码问题,要求每次都展示验证码 116 captchaShow: true, // 170306 因为暴力破解密码问题,要求每次都展示验证码
119 -  
120 - // 返回的URL链接  
121 backUrl: 'javascript:history.go(-1)', // eslint-disable-line 117 backUrl: 'javascript:history.go(-1)', // eslint-disable-line
122 showHeaderImg: true, // 控制显示头部图片 118 showHeaderImg: true, // 控制显示头部图片
123 isPassportPage: true, // 模板中模块标识 119 isPassportPage: true, // 模板中模块标识
@@ -167,13 +163,9 @@ const local = { @@ -167,13 +163,9 @@ const local = {
167 163
168 res.render('international', { 164 res.render('international', {
169 width750: true, 165 width750: true,
170 -  
171 - // 返回的URL链接  
172 backUrl: 'javascript:history.go(-1)', // eslint-disable-line 166 backUrl: 'javascript:history.go(-1)', // eslint-disable-line
173 loginInternational: true, // 模板中使用JS的标识 167 loginInternational: true, // 模板中使用JS的标识
174 useGeetest: _.get(req.app.locals.wap, 'geetest.validation', true), // 使用极验证 168 useGeetest: _.get(req.app.locals.wap, 'geetest.validation', true), // 使用极验证
175 -  
176 - // captchaShow: _.get(req.session, 'login.errorCount') <= 0,  
177 captchaShow: true, // 170306 因为暴力破解密码问题,要求每次都展示验证码 169 captchaShow: true, // 170306 因为暴力破解密码问题,要求每次都展示验证码
178 isPassportPage: true, // 模板中模块标识 170 isPassportPage: true, // 模板中模块标识
179 headerText: '登录', 171 headerText: '登录',
@@ -181,25 +173,21 @@ const local = { @@ -181,25 +173,21 @@ const local = {
181 countrys: RegService.getAreaData(), // 地区信息列表 173 countrys: RegService.getAreaData(), // 地区信息列表
182 module: 'passport', 174 module: 'passport',
183 page: 'international', 175 page: 'international',
184 - title: '国际账号登录' 176 + title: '国际账号登录',
  177 + loadJs: [
  178 + {
  179 + src: global.yoho.config.geetestJs
  180 + }
  181 + ]
185 }); 182 });
186 }, 183 },
187 login: (req, res, next) => { 184 login: (req, res, next) => {
188 185
189 - // 170306 因为暴力破解密码问题,要求每次都校验验证码  
190 - _.set(req.session, 'login.errorCount', 0);  
191 -  
192 - let count = _.get(req.session, 'login.errorCount');  
193 -  
194 - if (count == null) { // eslint-disable-line  
195 - _.set(req.session, 'login.errorCount', 3);  
196 - }  
197 -  
198 // 使用极验证 186 // 使用极验证
199 let useGeetest = _.get(req.app.locals.wap, 'geetest.validation', true); 187 let useGeetest = _.get(req.app.locals.wap, 'geetest.validation', true);
200 188
201 - // 有货自有验证码  
202 - if (count <= 0 && !useGeetest) { 189 + // 关闭极验证的时候使用有货自有验证码
  190 + if (!useGeetest) {
203 let captchaInput = req.body.captcha; 191 let captchaInput = req.body.captcha;
204 let captchaCode = _.get(req.session, 'captcha'); 192 let captchaCode = _.get(req.session, 'captcha');
205 let testCode = req.body.yohobuy; 193 let testCode = req.body.yohobuy;
@@ -212,7 +200,7 @@ const local = { @@ -212,7 +200,7 @@ const local = {
212 captchaShow: true 200 captchaShow: true
213 }; 201 };
214 202
215 - logger.info(`验证码校验结果${captchaInput.toString() === captchaCode},user:${captchaInput};server:${captchaCode}`); 203 + logger.info(`captcha validate result${captchaInput.toString() === captchaCode},user:${captchaInput};server:${captchaCode}`);
216 204
217 --req.session.captchaValidCount; 205 --req.session.captchaValidCount;
218 206
@@ -142,7 +142,7 @@ let verifyMobile = (req, res, next) => { @@ -142,7 +142,7 @@ let verifyMobile = (req, res, next) => {
142 req.session.captcha = null; 142 req.session.captcha = null;
143 data.changeCaptcha = true; 143 data.changeCaptcha = true;
144 } 144 }
145 - logger.info(`验证码校验结果${captcha.toString() === diffCaptcha},user:${captcha};server:${diffCaptcha}`); 145 + logger.info(`captcha validate result${captcha.toString() === diffCaptcha},user:${captcha};server:${diffCaptcha}`);
146 146
147 // error case: 验证码不匹配 147 // error case: 验证码不匹配
148 if (!(captcha === diffCaptcha || testCode === config.testCode)) { 148 if (!(captcha === diffCaptcha || testCode === config.testCode)) {
@@ -229,7 +229,7 @@ exports.indexCheck = (req, res, next) => { @@ -229,7 +229,7 @@ exports.indexCheck = (req, res, next) => {
229 } 229 }
230 230
231 231
232 - logger.info(`验证码校验结果${captcode.toString() === captcodeValid},user:${captcode};server:${captcodeValid}`); 232 + logger.info(`captcha validate result${captcode.toString() === captcodeValid},user:${captcode};server:${captcodeValid}`);
233 // 验证 233 // 验证
234 if ([area, mobile].some(val => val === '')) { 234 if ([area, mobile].some(val => val === '')) {
235 return em.emit('reject', Object.assign(errorData, { message: '请填写手机号'})); 235 return em.emit('reject', Object.assign(errorData, { message: '请填写手机号'}));