Merge remote-tracking branch 'refs/remotes/origin/feature/phoneCoupon' into develop
Showing
5 changed files
with
33 additions
and
9 deletions
@@ -85,7 +85,7 @@ exports.couponSend = (req, res, next) => { | @@ -85,7 +85,7 @@ exports.couponSend = (req, res, next) => { | ||
85 | 85 | ||
86 | // 接口要加 session 校验,跨域异步请求未添加相关参数 | 86 | // 接口要加 session 校验,跨域异步请求未添加相关参数 |
87 | if (req.yoho.isApp || app.client_type === 'miniapp') { | 87 | if (req.yoho.isApp || app.client_type === 'miniapp') { |
88 | - if (app.app_version && app.client_type && app.session_key && app.uid) { | 88 | + if (app.app_version && app.client_type && app.session_key && app.uid && !req.query.webSession) { |
89 | // 小程序调接口获取 session 的方式不同,H5 嵌小程序,client_type 标记为 h5 | 89 | // 小程序调接口获取 session 的方式不同,H5 嵌小程序,client_type 标记为 h5 |
90 | let isMiniApp = app.client_type === 'miniapp'; | 90 | let isMiniApp = app.client_type === 'miniapp'; |
91 | 91 |
@@ -25,7 +25,11 @@ const geetest = { | @@ -25,7 +25,11 @@ const geetest = { | ||
25 | } else { | 25 | } else { |
26 | req.session.useYohoCaptcha = true; | 26 | req.session.useYohoCaptcha = true; |
27 | } | 27 | } |
28 | - res.send(data); | 28 | + if (req.query.callback) { |
29 | + res.jsonp(data); | ||
30 | + } else { | ||
31 | + res.send(data); | ||
32 | + } | ||
29 | }).catch(next); | 33 | }).catch(next); |
30 | }, | 34 | }, |
31 | validate(req, res, next) { | 35 | validate(req, res, next) { |
@@ -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 | } |
@@ -169,6 +169,15 @@ router.get('/passport/sms_login', | @@ -169,6 +169,15 @@ router.get('/passport/sms_login', | ||
169 | validateCode.load, | 169 | validateCode.load, |
170 | smsLogin.smsLoginPage); // 短信验证码登录 | 170 | smsLogin.smsLoginPage); // 短信验证码登录 |
171 | router.post('/passport/sms_login/step1_check', validateCode.check, smsLogin.indexCheck); | 171 | router.post('/passport/sms_login/step1_check', validateCode.check, smsLogin.indexCheck); |
172 | +router.get('/passport/sms_login/step1_check', (req, res, next) => { | ||
173 | + if (!req.query.callback) { | ||
174 | + return res.json({code: 400}); | ||
175 | + } | ||
176 | + | ||
177 | + req.body = req.body || {}; | ||
178 | + Object.assign(req.body, req.query); | ||
179 | + next(); | ||
180 | +}, validateCode.check, smsLogin.indexCheck); | ||
172 | 181 | ||
173 | // 兼容老的路由 | 182 | // 兼容老的路由 |
174 | router.get('/signin.html', | 183 | router.get('/signin.html', |
@@ -7,7 +7,8 @@ const config = global.yoho.config; | @@ -7,7 +7,8 @@ const config = global.yoho.config; | ||
7 | 7 | ||
8 | module.exports = () => { | 8 | module.exports = () => { |
9 | return (req, res, next) => { | 9 | return (req, res, next) => { |
10 | - if (!req.yoho.isApp) { | 10 | + // webSession: 活动模板手机号领券,使用web端登录信息 |
11 | + if (!req.yoho.isApp || req.query.webSession) { | ||
11 | // 从 SESSION 中获取到当前登录用户的 UID | 12 | // 从 SESSION 中获取到当前登录用户的 UID |
12 | if (req.session && _.isNumber(req.session.LOGIN_UID_)) { | 13 | if (req.session && _.isNumber(req.session.LOGIN_UID_)) { |
13 | // 调用接口传参时切勿使用toString获得字符串 | 14 | // 调用接口传参时切勿使用toString获得字符串 |
-
Please register or login to post a comment