Authored by yyq

get coupon by phone number api-review by huangtao

... ... @@ -89,7 +89,11 @@ class SmsLogin {
co(function* () {
let sendSmsResult = yield req.ctx(PhoneServiceModel).sendSMS(params);
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);
}
... ...
... ... @@ -169,6 +169,15 @@ router.get('/passport/sms_login',
validateCode.load,
smsLogin.smsLoginPage); // 短信验证码登录
router.post('/passport/sms_login/step1_check', validateCode.check, smsLogin.indexCheck);
router.get('/passport/sms_login/step1_check', (req, res, next) => {
if (!req.query.callback) {
return res.json({code: 400});
}
req.body = req.body || {};
Object.assign(req.body, req.query);
next();
}, validateCode.check, smsLogin.indexCheck);
// 兼容老的路由
router.get('/signin.html',
... ...
... ... @@ -7,7 +7,8 @@ const config = global.yoho.config;
module.exports = () => {
return (req, res, next) => {
if (!req.yoho.isApp) {
// webSession: 活动模板手机号领券,使用web端登录信息
if (!req.yoho.isApp || req.query.webSession) {
// 从 SESSION 中获取到当前登录用户的 UID
if (req.session && _.isNumber(req.session.LOGIN_UID_)) {
// 调用接口传参时切勿使用toString获得字符串
... ...