|
@@ -68,14 +68,19 @@ const validateInputPage = (req, res, next) => { |
|
@@ -68,14 +68,19 @@ const validateInputPage = (req, res, next) => { |
68
|
req.inputInfo = result;
|
68
|
req.inputInfo = result;
|
69
|
next();
|
69
|
next();
|
70
|
})
|
70
|
})
|
71
|
- .catch(()=> {
|
|
|
72
|
- res.redirect(helpers.urlFormat('/passport/back/index'));
|
71
|
+ .catch((err) => {
|
|
|
72
|
+ res.json({
|
|
|
73
|
+ code: 400,
|
|
|
74
|
+ message: err
|
|
|
75
|
+ });
|
73
|
});
|
76
|
});
|
74
|
};
|
77
|
};
|
75
|
|
78
|
|
76
|
const getUserInfoAPI = (req, res, next) => {
|
79
|
const getUserInfoAPI = (req, res, next) => {
|
77
|
let inputInfo = req.inputInfo;
|
80
|
let inputInfo = req.inputInfo;
|
78
|
|
81
|
|
|
|
82
|
+ req.session.type = 'back-step1';
|
|
|
83
|
+
|
79
|
service.findUserAsync(inputInfo.type, inputInfo.phone, inputInfo.area)
|
84
|
service.findUserAsync(inputInfo.type, inputInfo.phone, inputInfo.area)
|
80
|
.then(result => {
|
85
|
.then(result => {
|
81
|
res.json(result);
|
86
|
res.json(result);
|
|
@@ -93,7 +98,13 @@ const sendCodePage = (req, res, next) => { |
|
@@ -93,7 +98,13 @@ const sendCodePage = (req, res, next) => { |
93
|
service.sendCodeToUserAsync(inputInfo.type, inputInfo.phone, inputInfo.area)
|
98
|
service.sendCodeToUserAsync(inputInfo.type, inputInfo.phone, inputInfo.area)
|
94
|
.then(result => {
|
99
|
.then(result => {
|
95
|
if (!(result.code && result.code === 200)) {
|
100
|
if (!(result.code && result.code === 200)) {
|
96
|
- return res.redirect(helpers.urlFormat('/passport/back/index'));
|
101
|
+ return res.json({
|
|
|
102
|
+ code: 400,
|
|
|
103
|
+ message: '发送验证码错误',
|
|
|
104
|
+ data: {
|
|
|
105
|
+ refer: helpers.urlFormat('/passport/back/index')
|
|
|
106
|
+ }
|
|
|
107
|
+ });
|
97
|
}
|
108
|
}
|
98
|
|
109
|
|
99
|
return next();
|
110
|
return next();
|
|
@@ -102,19 +113,45 @@ const sendCodePage = (req, res, next) => { |
|
@@ -102,19 +113,45 @@ const sendCodePage = (req, res, next) => { |
102
|
};
|
113
|
};
|
103
|
|
114
|
|
104
|
const saveInSession = (req, res) => {
|
115
|
const saveInSession = (req, res) => {
|
|
|
116
|
+ if (req.session.type !== 'back-step1') {
|
|
|
117
|
+ return res.json({
|
|
|
118
|
+ code: 400,
|
|
|
119
|
+ message: '未验证',
|
|
|
120
|
+ data: {
|
|
|
121
|
+ refer: helpers.urlFormat('/passport/back/index')
|
|
|
122
|
+ }
|
|
|
123
|
+ });
|
|
|
124
|
+ }
|
|
|
125
|
+
|
|
|
126
|
+ req.session.type = 'back-step2';
|
|
|
127
|
+
|
105
|
switch (req.inputInfo.type) {
|
128
|
switch (req.inputInfo.type) {
|
106
|
case 'email':
|
129
|
case 'email':
|
107
|
req.session.email = req.inputInfo.phone;
|
130
|
req.session.email = req.inputInfo.phone;
|
108
|
- res.redirect(helpers.urlFormat('/passport/back/sendEmail'));
|
|
|
109
|
- break;
|
131
|
+ return res.json({
|
|
|
132
|
+ code: 200,
|
|
|
133
|
+ data: {
|
|
|
134
|
+ refer: helpers.urlFormat('/passport/back/sendemail')
|
|
|
135
|
+ }
|
|
|
136
|
+ });
|
110
|
case 'mobile':
|
137
|
case 'mobile':
|
111
|
req.session.mobile = req.inputInfo.phone;
|
138
|
req.session.mobile = req.inputInfo.phone;
|
112
|
req.session.area = req.inputInfo.area;
|
139
|
req.session.area = req.inputInfo.area;
|
113
|
req.session.captcha = req.body.verifyCode;
|
140
|
req.session.captcha = req.body.verifyCode;
|
114
|
- res.redirect(helpers.urlFormat('/passport/back/verification'));
|
|
|
115
|
- break;
|
141
|
+
|
|
|
142
|
+ return res.json({
|
|
|
143
|
+ code: 200,
|
|
|
144
|
+ data: {
|
|
|
145
|
+ refer: helpers.urlFormat('/passport/back/verification')
|
|
|
146
|
+ }
|
|
|
147
|
+ });
|
116
|
default:
|
148
|
default:
|
117
|
- res.redirect(helpers.urlFormat('/passport/back/index'));
|
149
|
+ return res.json({
|
|
|
150
|
+ code: 500,
|
|
|
151
|
+ data: {
|
|
|
152
|
+ refer: helpers.urlFormat('/passport/back/index')
|
|
|
153
|
+ }
|
|
|
154
|
+ });
|
118
|
}
|
155
|
}
|
119
|
};
|
156
|
};
|
120
|
|
157
|
|
|
@@ -133,6 +170,10 @@ const validateMobileAPI = (req, res, next) => { |
|
@@ -133,6 +170,10 @@ const validateMobileAPI = (req, res, next) => { |
133
|
let mobile = req.body.mobile || '';
|
170
|
let mobile = req.body.mobile || '';
|
134
|
const ERR = {code: 400, message: '验证失败'};
|
171
|
const ERR = {code: 400, message: '验证失败'};
|
135
|
|
172
|
|
|
|
173
|
+ if (req.session.type !== 'back-step3') {
|
|
|
174
|
+ return res.json(ERR);
|
|
|
175
|
+ }
|
|
|
176
|
+
|
136
|
if (!passportHelper.validator.isMobile(mobile)) {
|
177
|
if (!passportHelper.validator.isMobile(mobile)) {
|
137
|
return res.json(ERR);
|
178
|
return res.json(ERR);
|
138
|
}
|
179
|
}
|
|
@@ -157,6 +198,12 @@ const validateEmailInSession = (req, res, next) => { |
|
@@ -157,6 +198,12 @@ const validateEmailInSession = (req, res, next) => { |
157
|
};
|
198
|
};
|
158
|
|
199
|
|
159
|
const sendEmailPage = (req, res, next) => {
|
200
|
const sendEmailPage = (req, res, next) => {
|
|
|
201
|
+ if (req.session.type !== 'back-step2') {
|
|
|
202
|
+ return res.redirect(helpers.urlFormat('/passport/back/index'));
|
|
|
203
|
+ }
|
|
|
204
|
+
|
|
|
205
|
+ req.session.type = 'back-step3';
|
|
|
206
|
+
|
160
|
passportHelper.getLeftBannerAsync()
|
207
|
passportHelper.getLeftBannerAsync()
|
161
|
.then(result => {
|
208
|
.then(result => {
|
162
|
res.render('back/send-email', Object.assign({
|
209
|
res.render('back/send-email', Object.assign({
|
|
@@ -215,7 +262,11 @@ const resetPasswordPage = (req, res, next) => { |
|
@@ -215,7 +262,11 @@ const resetPasswordPage = (req, res, next) => { |
215
|
};
|
262
|
};
|
216
|
|
263
|
|
217
|
const verifyCodeByMobilePage = (req, res, next) => {
|
264
|
const verifyCodeByMobilePage = (req, res, next) => {
|
218
|
- req.session.type = 'back-step2';
|
265
|
+ if (req.session.type !== 'back-step2') {
|
|
|
266
|
+ return res.redirect(helpers.urlFormat('/passport/back/index'));
|
|
|
267
|
+ }
|
|
|
268
|
+
|
|
|
269
|
+ req.session.type = 'back-step3';
|
219
|
|
270
|
|
220
|
passportHelper.getLeftBannerAsync()
|
271
|
passportHelper.getLeftBannerAsync()
|
221
|
.then(result => {
|
272
|
.then(result => {
|
|
@@ -282,7 +333,7 @@ const verifyCodeByMobileAPI = (req, res) => { |
|
@@ -282,7 +333,7 @@ const verifyCodeByMobileAPI = (req, res) => { |
282
|
return res.json(ERR);
|
333
|
return res.json(ERR);
|
283
|
}
|
334
|
}
|
284
|
|
335
|
|
285
|
- if (session.type !== 'back-step2') {
|
336
|
+ if (session.type !== 'back-step3') {
|
286
|
return res.json(ERR);
|
337
|
return res.json(ERR);
|
287
|
}
|
338
|
}
|
288
|
|
339
|
|
|
@@ -359,10 +410,9 @@ const updatePwdAPI = (req, res, next) => { |
|
@@ -359,10 +410,9 @@ const updatePwdAPI = (req, res, next) => { |
359
|
|
410
|
|
360
|
const validateMobileInSession = (req, res, next) => {
|
411
|
const validateMobileInSession = (req, res, next) => {
|
361
|
req.body.mobile = req.session.mobile || '';
|
412
|
req.body.mobile = req.session.mobile || '';
|
362
|
- req.body.verifyCode = req.session.captcha || '';
|
|
|
363
|
req.body.area = req.session.area || '';
|
413
|
req.body.area = req.session.area || '';
|
364
|
|
414
|
|
365
|
- if (!(req.body.mobile && req.body.verifyCode)) {
|
415
|
+ if (!req.body.mobile) {
|
366
|
return res.redirect(helpers.urlFormat('/passport/back/index'));
|
416
|
return res.redirect(helpers.urlFormat('/passport/back/index'));
|
367
|
}
|
417
|
}
|
368
|
|
418
|
|