Authored by 陈轩

fix

... ... @@ -230,7 +230,7 @@ const sendCodeToMobileAPI = (req, res, next) => {
};
if (req.session.captchaValidCount === 0) {
req.session.captcha = void 0; // 验证码 用过就扔
req.session.captcha = null; // 验证码 用过就扔
jsonData.changeCaptcha = true;
}
... ...
... ... @@ -161,31 +161,30 @@ const local = {
if (count == null) { // eslint-disable-line
_.set(req.session, 'login.errorCount', 3);
} else if (count <= 0) {
}
if (count <= 0) {
let captchaInput = req.body.captcha;
let captchaCode = _.get(req.session, 'captcha');
let errorCount = _.get(req.session, 'captchaValidCount', 4); // 初始1次 + 后续4次, 同一个验证码 共5次
let errorCount = _.get(req.session, 'captchaValidCount'); // 初始1次 + 后续4次, 同一个验证码 共5次
if (!errorCount) {
_.set(req.session, 'captchaValidCount', 4);
} else {
--req.session.captchaValidCount;
}
if (!captchaInput || !captchaCode || captchaInput !== captchaCode) {
let jsonData = {
code: 400,
message: '请将图片旋转到正确方向',
captchaShow: true
};
let jsonData = {
code: 400,
message: '请将图片旋转到正确方向',
captchaShow: true
};
--req.session.captchaValidCount;
if (req.session.captchaValidCount === 0) {
req.session.captcha = void 0; // 验证码 用过就扔
jsonData.changeCaptcha = true;
}
if (!errorCount) {
_.set(req.session, 'captchaValidCount', 5);
// delete req.session.captcha; // 验证码 用过就扔
req.session.captcha = null;
jsonData.changeCaptcha = true;
}
if (!(captchaInput && captchaCode && captchaInput === captchaCode)) {
res.json(jsonData);
return;
... ...
... ... @@ -162,7 +162,7 @@ exports.indexCheck = (req, res, next) => {
// 校验 失败
em.on('reject', error => {
if (req.session.captchaValidCount === 0) {
req.session.captcha = void 0; // 验证码 用过就扔
req.session.captcha = null; // 验证码 用过就扔
error.changeCaptcha = true;
}
... ... @@ -178,7 +178,7 @@ exports.indexCheck = (req, res, next) => {
return em.emit('reject', {code: 400, message: '请填写手机号'});
} else if (!captcode) {
return em.emit('reject', {code: 400, message: '请填写验证码'});
} else if (captcode !== captcodeValid) {
} else if (!(captcodeValid && captcode === captcodeValid)) {
return em.emit('reject', {code: 400, message: '请将图片旋转到正确位置'});
}
... ...