Authored by shijian

save

@@ -97,9 +97,15 @@ const requiredPost = (req, res) => { @@ -97,9 +97,15 @@ const requiredPost = (req, res) => {
97 } 97 }
98 }; 98 };
99 99
100 -const checkSendMobile = (req, res) => {  
101 - if (req.session.sendMobile && req.session.sendMobile !== req.query.mobile) {  
102 - req.session.sendMobile = ''; 100 +const checkSendMobile = (req, res, fromNode, mobile) => {
  101 + if (fromNode) { //node中判断
  102 + if (req.session.sendMobile && req.session.sendMobile !== mobile) {
  103 + return true;
  104 + } else {
  105 + return false;
  106 + }
  107 + }
  108 + if (req.session.sendMobile && req.session.sendMobile !== req.query.mobile) { //ajax中判断
103 return res.json({ 109 return res.json({
104 code: 400, 110 code: 400,
105 message: '验证码已失效' 111 message: '验证码已失效'
@@ -10,6 +10,7 @@ const UserService = require('../models/user-service'); @@ -10,6 +10,7 @@ const UserService = require('../models/user-service');
10 const LoginService = require('../models/login-service'); 10 const LoginService = require('../models/login-service');
11 const config = require('../../../config/common'); 11 const config = require('../../../config/common');
12 const safeRedirect = require('../../../doraemon/middleware/safe-redirect').safeRedirect; 12 const safeRedirect = require('../../../doraemon/middleware/safe-redirect').safeRedirect;
  13 +const captcha = require('./captcha');
13 14
14 let helpers = global.yoho.helpers; 15 let helpers = global.yoho.helpers;
15 let cache = global.yoho.cache; 16 let cache = global.yoho.cache;
@@ -156,7 +157,9 @@ let sendBindMsg = (req, res, next) => { @@ -156,7 +157,9 @@ let sendBindMsg = (req, res, next) => {
156 // 检查是否检查过 157 // 检查是否检查过
157 // let checkNum = yield cache.get(`regCheckMobileNum_${mobile}`); 158 // let checkNum = yield cache.get(`regCheckMobileNum_${mobile}`);
158 159
159 - if (req.session.hasGetSMS) { 160 + //检查上次的发送短信号码
  161 + if (captcha.checkSendMobile(req, res, true)) {
  162 + req.session.sendMobile = '';
160 data.message = '发送失败'; 163 data.message = '发送失败';
161 return res.json(data); 164 return res.json(data);
162 } 165 }
@@ -176,7 +179,8 @@ let sendBindMsg = (req, res, next) => { @@ -176,7 +179,8 @@ let sendBindMsg = (req, res, next) => {
176 179
177 return cache.set(sendCodeKey, sendCodeTimes + 1, 3600).then(() => { 180 return cache.set(sendCodeKey, sendCodeTimes + 1, 3600).then(() => {
178 if (result.code) { 181 if (result.code) {
179 - req.session.hasGetSMS = true; 182 + //记录发送短信的号码
  183 + req.session.sendMobile = mobile;
180 return res.json(result); 184 return res.json(result);
181 } else { 185 } else {
182 data.message = '发送失败'; 186 data.message = '发送失败';