...
|
...
|
@@ -89,7 +89,11 @@ class SmsLogin { |
|
|
co(function* () {
|
|
|
let sendSmsResult = yield req.ctx(PhoneServiceModel).sendSMS(params);
|
|
|
|
|
|
res.json(sendSmsResult);
|
|
|
if (req.query.callback) {
|
|
|
res.jsonp(sendSmsResult);
|
|
|
} else {
|
|
|
res.json(sendSmsResult);
|
|
|
}
|
|
|
})().catch(next);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -159,8 +163,14 @@ class SmsLogin { |
|
|
let shopping_key = cookie.getShoppingKey(req); // eslint-disable-line
|
|
|
let from = req.cookies.from || 'yohobuy';
|
|
|
|
|
|
if (req.query.callback) {
|
|
|
res._sendFn = res.jsonp;
|
|
|
} else {
|
|
|
res._sendFn = res.json;
|
|
|
}
|
|
|
|
|
|
if (!mobile || !area) {
|
|
|
res.json({
|
|
|
res._sendFn({
|
|
|
code: 401,
|
|
|
message: VERIFY_ERROR
|
|
|
});
|
...
|
...
|
@@ -171,13 +181,13 @@ class SmsLogin { |
|
|
|
|
|
// 验证码 校验异常
|
|
|
if (r2.code !== 200) {
|
|
|
res.json(r2);
|
|
|
res._sendFn(r2);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 校验失败
|
|
|
if (r2.data.is_pass !== 'Y') {
|
|
|
res.json({
|
|
|
res._sendFn({
|
|
|
code: 401,
|
|
|
message: '短信验证码错误'
|
|
|
});
|
...
|
...
|
@@ -218,7 +228,7 @@ class SmsLogin { |
|
|
});
|
|
|
return req.ctx(AuthHelperModel).syncUserSession(info.data.uid, req, res, info.data.session_key);
|
|
|
}).then((authData) => {
|
|
|
res.json({
|
|
|
res._sendFn({
|
|
|
code: 200,
|
|
|
message: LOGIN_SUCCSS,
|
|
|
redirect: _.get(authData, 'refer') || utils.refererLimit(req.cookies.refer),
|
...
|
...
|
@@ -228,7 +238,7 @@ class SmsLogin { |
|
|
|
|
|
delete req.session.smsLogin;
|
|
|
}).catch(error => {
|
|
|
res.json(error);
|
|
|
res._sendFn(error);
|
|
|
});
|
|
|
}).catch(next);
|
|
|
}
|
...
|
...
|
|