Authored by 陈轩

fix

@@ -236,6 +236,9 @@ const sendCodeToMobileAPI = (req, res, next) => { @@ -236,6 +236,9 @@ const sendCodeToMobileAPI = (req, res, next) => {
236 236
237 return res.json(jsonData); 237 return res.json(jsonData);
238 } 238 }
  239 +
  240 + _.set(req.session, 'captcha', null);
  241 +
239 } else if (!req.session.backupCaptch.verifyResult) { 242 } else if (!req.session.backupCaptch.verifyResult) {
240 243
241 return res.json({ 244 return res.json({
@@ -254,6 +257,8 @@ const sendCodeToMobileAPI = (req, res, next) => { @@ -254,6 +257,8 @@ const sendCodeToMobileAPI = (req, res, next) => {
254 return res.json(ERR); 257 return res.json(ERR);
255 } 258 }
256 259
  260 +
  261 +
257 service.sendCodeToMobileAsync(phoneNum, areaCode) 262 service.sendCodeToMobileAsync(phoneNum, areaCode)
258 .then(result => { 263 .then(result => {
259 if (_.isEmpty(result) || result.code !== 200) { 264 if (_.isEmpty(result) || result.code !== 200) {
@@ -137,6 +137,10 @@ exports.indexCheck = (req, res, next) => { @@ -137,6 +137,10 @@ exports.indexCheck = (req, res, next) => {
137 137
138 138
139 let errorCount = _.get(req.session, 'captchaValidCount', 4 - 1); // 初始1次 + 后续4次, 同一个验证码 共5次 139 let errorCount = _.get(req.session, 'captchaValidCount', 4 - 1); // 初始1次 + 后续4次, 同一个验证码 共5次
  140 + let errorData = {
  141 + code: 400,
  142 + message: ''
  143 + };
140 144
141 if (!errorCount) { 145 if (!errorCount) {
142 _.set(req.session, 'captchaValidCount', 3); 146 _.set(req.session, 'captchaValidCount', 3);
@@ -150,6 +154,7 @@ exports.indexCheck = (req, res, next) => { @@ -150,6 +154,7 @@ exports.indexCheck = (req, res, next) => {
150 _.set(req.session, 'smsLogin.area', area); 154 _.set(req.session, 'smsLogin.area', area);
151 _.set(req.session, 'smsLogin.mobile', mobile); 155 _.set(req.session, 'smsLogin.mobile', mobile);
152 _.set(req.session, 'smsLogin.step', 2); 156 _.set(req.session, 'smsLogin.step', 2);
  157 + req.session.captcha = null;
153 158
154 PhoneService.sendSMS(mobile, area, 1); 159 PhoneService.sendSMS(mobile, area, 1);
155 160
@@ -161,25 +166,25 @@ exports.indexCheck = (req, res, next) => { @@ -161,25 +166,25 @@ exports.indexCheck = (req, res, next) => {
161 166
162 // 校验 失败 167 // 校验 失败
163 em.on('reject', error => { 168 em.on('reject', error => {
164 - if (req.session.captchaValidCount === 0) {  
165 - req.session.captcha = null; // 验证码 用过就扔  
166 - error.changeCaptcha = true;  
167 - }  
168 -  
169 _.set(req.session, 'smsLogin.step', 1); 169 _.set(req.session, 'smsLogin.step', 1);
170 170
171 171
172 res.json(error); 172 res.json(error);
173 }); 173 });
174 174
  175 + if (req.session.captchaValidCount === 0) {
  176 + req.session.captcha = null; // 验证码 用过就扔
  177 + errorData.changeCaptcha = true;
  178 + }
  179 +
175 180
176 // 验证 181 // 验证
177 if ([area, mobile].some(val => val === '')) { 182 if ([area, mobile].some(val => val === '')) {
178 - return em.emit('reject', {code: 400, message: '请填写手机号'}); 183 + return em.emit('reject', Object.assign(errorData, { message: '请填写手机号'}));
179 } else if (!captcode) { 184 } else if (!captcode) {
180 - return em.emit('reject', {code: 400, message: '请填写验证码'}); 185 + return em.emit('reject', Object.assign(errorData, {message: '请填写验证码'}));
181 } else if (!(captcodeValid && captcode === captcodeValid)) { 186 } else if (!(captcodeValid && captcode === captcodeValid)) {
182 - return em.emit('reject', {code: 400, message: '请将图片旋转到正确位置'}); 187 + return em.emit('reject', Object.assign(errorData, {message: '请将图片旋转到正确位置'}));
183 } 188 }
184 189
185 // congratulation~~ 190 // congratulation~~