Authored by 陈轩

fix

... ... @@ -236,6 +236,9 @@ const sendCodeToMobileAPI = (req, res, next) => {
return res.json(jsonData);
}
_.set(req.session, 'captcha', null);
} else if (!req.session.backupCaptch.verifyResult) {
return res.json({
... ... @@ -254,6 +257,8 @@ const sendCodeToMobileAPI = (req, res, next) => {
return res.json(ERR);
}
service.sendCodeToMobileAsync(phoneNum, areaCode)
.then(result => {
if (_.isEmpty(result) || result.code !== 200) {
... ...
... ... @@ -137,6 +137,10 @@ exports.indexCheck = (req, res, next) => {
let errorCount = _.get(req.session, 'captchaValidCount', 4 - 1); // 初始1次 + 后续4次, 同一个验证码 共5次
let errorData = {
code: 400,
message: ''
};
if (!errorCount) {
_.set(req.session, 'captchaValidCount', 3);
... ... @@ -150,6 +154,7 @@ exports.indexCheck = (req, res, next) => {
_.set(req.session, 'smsLogin.area', area);
_.set(req.session, 'smsLogin.mobile', mobile);
_.set(req.session, 'smsLogin.step', 2);
req.session.captcha = null;
PhoneService.sendSMS(mobile, area, 1);
... ... @@ -161,25 +166,25 @@ exports.indexCheck = (req, res, next) => {
// 校验 失败
em.on('reject', error => {
if (req.session.captchaValidCount === 0) {
req.session.captcha = null; // 验证码 用过就扔
error.changeCaptcha = true;
}
_.set(req.session, 'smsLogin.step', 1);
res.json(error);
});
if (req.session.captchaValidCount === 0) {
req.session.captcha = null; // 验证码 用过就扔
errorData.changeCaptcha = true;
}
// 验证
if ([area, mobile].some(val => val === '')) {
return em.emit('reject', {code: 400, message: '请填写手机号'});
return em.emit('reject', Object.assign(errorData, { message: '请填写手机号'}));
} else if (!captcode) {
return em.emit('reject', {code: 400, message: '请填写验证码'});
return em.emit('reject', Object.assign(errorData, {message: '请填写验证码'}));
} else if (!(captcodeValid && captcode === captcodeValid)) {
return em.emit('reject', {code: 400, message: '请将图片旋转到正确位置'});
return em.emit('reject', Object.assign(errorData, {message: '请将图片旋转到正确位置'}));
}
// congratulation~~
... ...