|
@@ -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~~
|