|
@@ -89,7 +89,11 @@ class SmsLogin { |
|
@@ -89,7 +89,11 @@ class SmsLogin { |
89
|
co(function* () {
|
89
|
co(function* () {
|
90
|
let sendSmsResult = yield req.ctx(PhoneServiceModel).sendSMS(params);
|
90
|
let sendSmsResult = yield req.ctx(PhoneServiceModel).sendSMS(params);
|
91
|
|
91
|
|
92
|
- res.json(sendSmsResult);
|
92
|
+ if (req.query.callback) {
|
|
|
93
|
+ res.jsonp(sendSmsResult);
|
|
|
94
|
+ } else {
|
|
|
95
|
+ res.json(sendSmsResult);
|
|
|
96
|
+ }
|
93
|
})().catch(next);
|
97
|
})().catch(next);
|
94
|
}
|
98
|
}
|
95
|
|
99
|
|
|
@@ -159,8 +163,14 @@ class SmsLogin { |
|
@@ -159,8 +163,14 @@ class SmsLogin { |
159
|
let shopping_key = cookie.getShoppingKey(req); // eslint-disable-line
|
163
|
let shopping_key = cookie.getShoppingKey(req); // eslint-disable-line
|
160
|
let from = req.cookies.from || 'yohobuy';
|
164
|
let from = req.cookies.from || 'yohobuy';
|
161
|
|
165
|
|
|
|
166
|
+ if (req.query.callback) {
|
|
|
167
|
+ res._sendFn = res.jsonp;
|
|
|
168
|
+ } else {
|
|
|
169
|
+ res._sendFn = res.json;
|
|
|
170
|
+ }
|
|
|
171
|
+
|
162
|
if (!mobile || !area) {
|
172
|
if (!mobile || !area) {
|
163
|
- res.json({
|
173
|
+ res._sendFn({
|
164
|
code: 401,
|
174
|
code: 401,
|
165
|
message: VERIFY_ERROR
|
175
|
message: VERIFY_ERROR
|
166
|
});
|
176
|
});
|
|
@@ -171,13 +181,13 @@ class SmsLogin { |
|
@@ -171,13 +181,13 @@ class SmsLogin { |
171
|
|
181
|
|
172
|
// 验证码 校验异常
|
182
|
// 验证码 校验异常
|
173
|
if (r2.code !== 200) {
|
183
|
if (r2.code !== 200) {
|
174
|
- res.json(r2);
|
184
|
+ res._sendFn(r2);
|
175
|
return;
|
185
|
return;
|
176
|
}
|
186
|
}
|
177
|
|
187
|
|
178
|
// 校验失败
|
188
|
// 校验失败
|
179
|
if (r2.data.is_pass !== 'Y') {
|
189
|
if (r2.data.is_pass !== 'Y') {
|
180
|
- res.json({
|
190
|
+ res._sendFn({
|
181
|
code: 401,
|
191
|
code: 401,
|
182
|
message: '短信验证码错误'
|
192
|
message: '短信验证码错误'
|
183
|
});
|
193
|
});
|
|
@@ -218,7 +228,7 @@ class SmsLogin { |
|
@@ -218,7 +228,7 @@ class SmsLogin { |
218
|
});
|
228
|
});
|
219
|
return req.ctx(AuthHelperModel).syncUserSession(info.data.uid, req, res, info.data.session_key);
|
229
|
return req.ctx(AuthHelperModel).syncUserSession(info.data.uid, req, res, info.data.session_key);
|
220
|
}).then((authData) => {
|
230
|
}).then((authData) => {
|
221
|
- res.json({
|
231
|
+ res._sendFn({
|
222
|
code: 200,
|
232
|
code: 200,
|
223
|
message: LOGIN_SUCCSS,
|
233
|
message: LOGIN_SUCCSS,
|
224
|
redirect: _.get(authData, 'refer') || utils.refererLimit(req.cookies.refer),
|
234
|
redirect: _.get(authData, 'refer') || utils.refererLimit(req.cookies.refer),
|
|
@@ -228,7 +238,7 @@ class SmsLogin { |
|
@@ -228,7 +238,7 @@ class SmsLogin { |
228
|
|
238
|
|
229
|
delete req.session.smsLogin;
|
239
|
delete req.session.smsLogin;
|
230
|
}).catch(error => {
|
240
|
}).catch(error => {
|
231
|
- res.json(error);
|
241
|
+ res._sendFn(error);
|
232
|
});
|
242
|
});
|
233
|
}).catch(next);
|
243
|
}).catch(next);
|
234
|
}
|
244
|
}
|