Authored by shijian

Merge branch 'feature/safe-bug' of http://git.yoho.cn/fe/yoho-blk into feature/safe-bug

... ... @@ -57,6 +57,7 @@ const generate = (req, res) => {
let length = +(req.query.l || 4);
let captcha = captchaService.generateCaptcha(width, height, length);
req.session.sendMobile = '';
req.session.captcha = captcha.text;
req.session.captchaCount = 0;
... ... @@ -97,31 +98,9 @@ const requiredPost = (req, res) => {
}
};
const checkSendMobile = (req, res, fromNode, mobile) => {
if (fromNode) { // node中判断
if (req.session.sendMobile && req.session.sendMobile !== mobile) {
return true;
} else {
return false;
}
}
if (req.session.sendMobile && req.session.sendMobile !== req.query.mobile) { // ajax中判断
return res.json({
code: 400,
message: '验证码已失效'
});
} else {
return res.json({
code: 200,
data: {}
});
}
};
module.exports = {
requiredAPI,
requiredPage,
generate,
requiredPost,
checkSendMobile
requiredPost
};
... ...
... ... @@ -241,6 +241,15 @@ const local = {
message: '格式错误'
});
}
if (req.session.sendMobile && req.session.sendMobile !== mobile) { // ajax中判断
req.session.sendMobile = '';
req.session.captcha = '';
return res.json({
code: 400,
message: '验证码已失效'
});
}
LoginService.sendPasswordBySMS(area, mobile).then((result) => {
if (result && result.code === 200) {
... ...
... ... @@ -159,6 +159,5 @@ router.get('/back/resetSuccess',
router.get('/images', captcha.generate);
router.post('/images/check', captcha.requiredPost);
router.get('/captcha/checkSendMobile', captcha.checkSendMobile);
module.exports = router;
... ...
... ... @@ -48,7 +48,7 @@ var upDown = {
var selectedIcon = '';
// 短信验证码的计数器,60s
var secondCount = 5;
var secondCount = 60;
// 短信验证码只能验证一次
var isSmsCheckedSuccessFlag = false;
... ... @@ -486,7 +486,7 @@ ep.on('smsCode', function(auth) {
function disable60sSendSmsBtn() {
secondCount -= 1;
if (secondCount < 0) {
secondCount = 5;
secondCount = 60;
$smsBtn.val('获取短信验证码')
.removeClass('second-progress')
.removeClass('disable');
... ... @@ -509,7 +509,7 @@ function sendCaptchaSmsAsync() {
verifyCode: $.trim($imgCaptchaInput.val())
}
}).then(function(data) {
if (data.captchaCount === false) {
if (data.captchaCount === false || data.code === 400) {
errTip($imgCaptchaInput, data.message);
ep.emit('captcha', false);
refreshCaptcha();
... ... @@ -659,26 +659,6 @@ $smsBtn.on('mousedown', function() {
return validateCaptchaImg(true);
})
.then(function() {
var defer = $.Deferred();
return $.ajax({
type: 'GET',
url: '/passport/captcha/checkSendMobile',
data: {
mobile: getMoblie()
}
}).then(function(data) {
if (data.code === 400) {
errTip($imgCaptchaInput, data.message);
ep.emit('captcha', false);
refreshCaptcha();
return defer.reject(false);
} else {
return true;
}
});
})
.then(function() {
disable60sSendSmsBtn();
return sendCaptchaSmsAsync();
});
... ...