Authored by htoooth

Merge branch 'hotfix/gee-captcha-check' into release/5.5.1

... ... @@ -104,7 +104,10 @@ app.use(CookieSession({ // eslint-disable-line
requestKey: 'session2',
cookieName: 'yohobuy_session_cookie',
secret: '82dd7e724f2c6870472c89dfa43cf48d',
domain: config.cookieDomain
cookie: {
domain: config.cookieDomain,
ephemeral: true
}
}));
app.use((req, res, next) => {
... ...
... ... @@ -110,7 +110,7 @@ const saveInSession = (req, res) => {
case 'mobile':
req.session.mobile = req.inputInfo.phone;
req.session.area = req.inputInfo.area;
req.session.verifyCode = req.session.captcha;
req.session.captcha = req.body.verifyCode;
res.redirect(helpers.urlFormat('/passport/back/verification'));
break;
default:
... ...
... ... @@ -15,25 +15,7 @@ const CAPTCHA = config.UNIVERSAL_CAPTCHA;
// 对比函数
const _mustEqual = (req) => {
let count = req.session.captchaCount;
if (!req.session.captcha) {
return false;
}
if (count >= 4) {
req.session.captcha = CAPTCHA;
return false;
}
req.session.captchaCount = count + 1;
let result = req.body.verifyCode === req.session.captcha ||
req.body.verifyCode === CAPTCHA;
logger.info(`geetest captcha auth [${result ? 'fail' : 'success'}]`,
`CLIENT [${req.body.verifyCode}] SERVER [${req.session.captcha}]`);
return result;
return req.body.verifyCode === CAPTCHA;
};
var pcGeetest = new Geetest({
... ... @@ -51,7 +33,6 @@ const generate = (req, res) => {
res.send(data);
} else {
// 正常模式
req.session.captchaCount = 0;
res.send(data);
}
});
... ... @@ -93,7 +74,6 @@ const requiredAPI = (req, res, next) => {
code: 401
});
} else {
req.session.captcha = verifyCode;
return next();
}
});
... ...
... ... @@ -184,6 +184,8 @@ let sendBindMsg = (req, res, next) => {
/* 向手机发送注册验证码 */
let result = yield regService.sendCodeToMobile(area, mobile);
req.session.type = 'register-step1';
return cache.set(sendCodeKey, sendCodeTimes + 1, 3600).then(() => {
if (result.code) {
return res.json(result);
... ... @@ -229,6 +231,10 @@ let mobileRegister = (req, res, next) => {
data: ''
};
if (req.session.type !== 'register-step1') {
return res.json(data);
}
/* 判断是否是有效的注册方式,防注册机刷 */
let regExpireTime = req.session.REG_EXPIRE_;
... ... @@ -273,6 +279,9 @@ let mobileRegister = (req, res, next) => {
return res.json(data);
}
// 清除 session type
req.session.type = '';
return loginService.syncUserSession(regResult.data.uid, req, res).then(() => {
return res.json({
code: 200,
... ...
... ... @@ -107,7 +107,6 @@ router.post('/passport/reg/sendBindMsg',
reg.sendBindMsg);
router.post('/passport/reg/mobileregister',
captcha.requiredAPI,
reg.checkMobileMiddleware,
reg.checkPassword,
reg.mobileRegister);
... ...
... ... @@ -31,7 +31,7 @@
</li>
<li class="input-container-li clearfix">
<input name="refer" id="refer" type="hidden" value="http%3A%2F%2Fwww.yohobuy.com%2F">
<input id="find-btn" class="btn find-btn disable" type="submit" value="下一步" disabled="">
<input id="find-btn" class="btn find-btn" type="submit" value="下一步" disabled="">
</li>
</ul>
</form>
... ...
... ... @@ -14,5 +14,6 @@ $('.confirm').on('click', function() {
});
});
captcha.onSuccess(function() {
$('.confirm').trigger('click');
});
... ...
... ... @@ -193,12 +193,10 @@ function checkAllForm() {
arr[key] = checkForm($(item));
});
if (captcha.$container.length !== 0) {
captcha.check().then(function() {
arr.push(true);
}).fail(function() {
arr.push(false);
});
if (captcha.getResults() !== '') {
arr.push(true);
} else {
arr.push(false);
}
if (arr.indexOf(false) >= 0) {
... ...
... ... @@ -38,31 +38,6 @@ function enableBtn() {
}
}
function authcode() {
return $.ajax({
type: 'POST',
url: '/passport/back/authcode',
data: {
verifyCode: captcha.getResults(),
phoneNum: $phoneNum.val(),
area: $cr.val()
}
}).then(function(data) {
if (data.code === 200) {
$('#captcha-value').val(captcha.getResults());
return $.Deferred().resolve().promise(); //eslint-disable-line
} else if (data.code === 402) {
$accErr.removeClass('hide').find('em').text('该账号不存在');
$phoneNum.addClass('error');
return $.Deferred().reject().promise();//eslint-disable-line
} else if (data.code === 400) {
captcha.showTip();
return $.Deferred().reject().promise();//eslint-disable-line
}
});
}
function vaPn(v) {
var pass = true,
errTxt = '';
... ... @@ -168,14 +143,10 @@ $('#find-btn').click(function(e) {
$('#find-form').attr('action', '/passport/back/mobile');
}
if ($(this).hasClass('disable')) {
return;
}
$('#captcha-value').val(captcha.getResults());
if (hasPh) {
authcode().then(function() {
$('#back-form').submit();
});
$('#back-form').submit();
}
e.preventDefault();
... ...
... ... @@ -160,13 +160,10 @@ function phoneAjaxFn(page, callback) {
// 图形验证码ajax校验
function picCaptchaAjaxFn(callback) {
return captchaImage.check().then(function() {
validateResult[1].message = '';
validateResult[1].status = true;
}).fail(function() {
validateResult[1].message = 'err';
validateResult[1].status = false;
}).always(callback);
validateResult[1].message = '';
validateResult[1].status = true;
$.Deferred().resolve().promise().always(callback); // eslint-disable-line
}
// 短信验证码ajax校验
... ...
... ... @@ -102,6 +102,10 @@ GeeCaptcha.prototype = {
return $.Deferred().reject().promise(); // eslint-disable-line
}
if (!this.checkURI) {
return $.Deferred().reject().promise(); // eslint-disable-line
}
return $.post(this.checkURI, {
verifyCode: _this.getResults()
}).then(function(result) {
... ...