Authored by shijian

save

... ... @@ -97,9 +97,15 @@ const requiredPost = (req, res) => {
}
};
const checkSendMobile = (req, res) => {
if (req.session.sendMobile && req.session.sendMobile !== req.query.mobile) {
req.session.sendMobile = '';
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: '验证码已失效'
... ...
... ... @@ -10,6 +10,7 @@ const UserService = require('../models/user-service');
const LoginService = require('../models/login-service');
const config = require('../../../config/common');
const safeRedirect = require('../../../doraemon/middleware/safe-redirect').safeRedirect;
const captcha = require('./captcha');
let helpers = global.yoho.helpers;
let cache = global.yoho.cache;
... ... @@ -156,7 +157,9 @@ let sendBindMsg = (req, res, next) => {
// 检查是否检查过
// let checkNum = yield cache.get(`regCheckMobileNum_${mobile}`);
if (req.session.hasGetSMS) {
//检查上次的发送短信号码
if (captcha.checkSendMobile(req, res, true)) {
req.session.sendMobile = '';
data.message = '发送失败';
return res.json(data);
}
... ... @@ -176,7 +179,8 @@ let sendBindMsg = (req, res, next) => {
return cache.set(sendCodeKey, sendCodeTimes + 1, 3600).then(() => {
if (result.code) {
req.session.hasGetSMS = true;
//记录发送短信的号码
req.session.sendMobile = mobile;
return res.json(result);
} else {
data.message = '发送失败';
... ...