Authored by shijian

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

... ... @@ -97,9 +97,25 @@ const requiredPost = (req, res) => {
}
};
const checkSendMobile = (req, res) => {
if (req.session.sendMobile && req.session.sendMobile !== req.query.mobile) {
req.session.sendMobile = '';
return res.json({
code: 400,
message: '验证码已失效'
});
} else {
return res.json({
code: 200,
data: {}
})
}
}
module.exports = {
requiredAPI,
requiredPage,
generate,
requiredPost
requiredPost,
checkSendMobile
};
... ...
... ... @@ -243,6 +243,10 @@ const local = {
}
LoginService.sendPasswordBySMS(area, mobile).then((result) => {
if (result && result.code === 200) {
req.session.sendMobile = mobile;
}
return res.json(result);
}).catch(next);
},
... ...
... ... @@ -159,4 +159,6 @@ 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 = 60;
var secondCount = 5;
// 短信验证码只能验证一次
var isSmsCheckedSuccessFlag = false;
... ... @@ -486,7 +486,7 @@ ep.on('smsCode', function(auth) {
function disable60sSendSmsBtn() {
secondCount -= 1;
if (secondCount < 0) {
secondCount = 60;
secondCount = 5;
$smsBtn.val('获取短信验证码')
.removeClass('second-progress')
.removeClass('disable');
... ... @@ -659,6 +659,26 @@ $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();
});
... ...