conflict-handle
Showing
8 changed files
with
41 additions
and
10 deletions
@@ -36,6 +36,7 @@ passport.use(new LocalStrategy({ | @@ -36,6 +36,7 @@ passport.use(new LocalStrategy({ | ||
36 | let area = req.body.areaCode || '86'; | 36 | let area = req.body.areaCode || '86'; |
37 | let clientIp = req.yoho.clientIp || ''; | 37 | let clientIp = req.yoho.clientIp || ''; |
38 | let isSkip = req.body.isskip; | 38 | let isSkip = req.body.isskip; |
39 | + let from = req.cookies.from || 'yohobuy'; | ||
39 | 40 | ||
40 | if (isNaN(parseInt(area, 0)) || _.isEmpty(username) || _.isEmpty(password)) { | 41 | if (isNaN(parseInt(area, 0)) || _.isEmpty(username) || _.isEmpty(password)) { |
41 | logger.info(`【Passport Login】bad params, area:${area} account:${username} password:${password}`); | 42 | logger.info(`【Passport Login】bad params, area:${area} account:${username} password:${password}`); |
@@ -66,7 +67,7 @@ passport.use(new LocalStrategy({ | @@ -66,7 +67,7 @@ passport.use(new LocalStrategy({ | ||
66 | 67 | ||
67 | let shoppingKey = cookie.getShoppingKey(req); | 68 | let shoppingKey = cookie.getShoppingKey(req); |
68 | 69 | ||
69 | - AuthHelper.signinAes(area, username, password, shoppingKey, clientIp, isSkip).then((result) => { | 70 | + AuthHelper.signinAes(area, username, password, shoppingKey, clientIp, isSkip, from).then((result) => { |
70 | if (result.code && result.code === 200 && result.data.uid) { | 71 | if (result.code && result.code === 200 && result.data.uid) { |
71 | done(null, result.data); | 72 | done(null, result.data); |
72 | } else if (result.code && result.code === 4189) { | 73 | } else if (result.code && result.code === 4189) { |
@@ -149,6 +149,16 @@ const common = { | @@ -149,6 +149,16 @@ const common = { | ||
149 | refer && !/signin|login|passport/.test(refer) && res.cookie('refer', encodeURI(refer), { | 149 | refer && !/signin|login|passport/.test(refer) && res.cookie('refer', encodeURI(refer), { |
150 | domain: 'yohobuy.com' | 150 | domain: 'yohobuy.com' |
151 | }); | 151 | }); |
152 | + | ||
153 | + let from = req.query.from; | ||
154 | + | ||
155 | + if (from) { | ||
156 | + res.cookie('from', from, { | ||
157 | + domain: 'yohobuy.com', | ||
158 | + expires: new Date(Date.now() + 10 * 60 * 1000) | ||
159 | + }); | ||
160 | + } | ||
161 | + | ||
152 | if (req.yoho.isApp) { | 162 | if (req.yoho.isApp) { |
153 | return next({ | 163 | return next({ |
154 | code: 401, | 164 | code: 401, |
@@ -85,6 +85,7 @@ class Reg { | @@ -85,6 +85,7 @@ class Reg { | ||
85 | let inviteCode = req.body.inviteCode || ''; | 85 | let inviteCode = req.body.inviteCode || ''; |
86 | let isFromMy = _.get(req.session, 'phoneReg.isFromMy', '0'); | 86 | let isFromMy = _.get(req.session, 'phoneReg.isFromMy', '0'); |
87 | let token = req.body.token; | 87 | let token = req.body.token; |
88 | + let from = req.cookies.from || 'yohobuy'; | ||
88 | 89 | ||
89 | // 购物车key | 90 | // 购物车key |
90 | let shoppingKey = cookie.getShoppingKey(req); | 91 | let shoppingKey = cookie.getShoppingKey(req); |
@@ -121,7 +122,7 @@ class Reg { | @@ -121,7 +122,7 @@ class Reg { | ||
121 | } | 122 | } |
122 | 123 | ||
123 | let regMobileAesResult = yield RegService.regMobileAes(area, mobile, password, | 124 | let regMobileAesResult = yield RegService.regMobileAes(area, mobile, password, |
124 | - shoppingKey, smsCode, inviteCode, isFromMy); | 125 | + shoppingKey, smsCode, inviteCode, isFromMy, from); |
125 | 126 | ||
126 | if (regMobileAesResult.code !== 200 || !regMobileAesResult.data || | 127 | if (regMobileAesResult.code !== 200 || !regMobileAesResult.data || |
127 | !regMobileAesResult.data.uid) { | 128 | !regMobileAesResult.data.uid) { |
@@ -99,7 +99,7 @@ class SmsLogin { | @@ -99,7 +99,7 @@ class SmsLogin { | ||
99 | 99 | ||
100 | // 验证 | 100 | // 验证 |
101 | if ([area, mobile].some(val => val === '')) { | 101 | if ([area, mobile].some(val => val === '')) { |
102 | - return em.emit('reject', Object.assign(errorData, { message: '请填写手机号'})); | 102 | + return em.emit('reject', Object.assign(errorData, { message: '请填写手机号' })); |
103 | } | 103 | } |
104 | 104 | ||
105 | // congratulation~~ | 105 | // congratulation~~ |
@@ -201,6 +201,7 @@ class SmsLogin { | @@ -201,6 +201,7 @@ class SmsLogin { | ||
201 | const mobile = _.get(req.session, 'smsLogin.mobile', ''); | 201 | const mobile = _.get(req.session, 'smsLogin.mobile', ''); |
202 | const area = _.get(req.session, 'smsLogin.area', ''); | 202 | const area = _.get(req.session, 'smsLogin.area', ''); |
203 | const shopping_key = cookie.getShoppingKey(req); // eslint-disable-line | 203 | const shopping_key = cookie.getShoppingKey(req); // eslint-disable-line |
204 | + let from = req.cookies.from || 'yohobuy'; | ||
204 | 205 | ||
205 | if (!mobile || !area) { | 206 | if (!mobile || !area) { |
206 | res.json({ | 207 | res.json({ |
@@ -261,7 +262,8 @@ class SmsLogin { | @@ -261,7 +262,8 @@ class SmsLogin { | ||
261 | profile: mobile, | 262 | profile: mobile, |
262 | code: r2.data.code, | 263 | code: r2.data.code, |
263 | area, | 264 | area, |
264 | - shopping_key | 265 | + shopping_key, |
266 | + from | ||
265 | }) | 267 | }) |
266 | .then(info => { | 268 | .then(info => { |
267 | if (info.code !== 200) { | 269 | if (info.code !== 200) { |
@@ -309,6 +311,7 @@ class SmsLogin { | @@ -309,6 +311,7 @@ class SmsLogin { | ||
309 | let password = (req.body.password || '').trim(); | 311 | let password = (req.body.password || '').trim(); |
310 | let registerCode = req.body.registerCode || ''; | 312 | let registerCode = req.body.registerCode || ''; |
311 | let clientIp = req.yoho.clientIp || ''; | 313 | let clientIp = req.yoho.clientIp || ''; |
314 | + let from = req.cookies.from || 'yohobuy'; | ||
312 | 315 | ||
313 | if (!password) { | 316 | if (!password) { |
314 | data.message = PASSWORD_REQUIRED; | 317 | data.message = PASSWORD_REQUIRED; |
@@ -331,7 +334,8 @@ class SmsLogin { | @@ -331,7 +334,8 @@ class SmsLogin { | ||
331 | // 验证注册的标识码是否有效 | 334 | // 验证注册的标识码是否有效 |
332 | let resultCopy = null; | 335 | let resultCopy = null; |
333 | 336 | ||
334 | - RegService.regMobileAes(area, mobile, password, shoppingKey, registerCode, null, clientIp).then(result => { | 337 | + RegService.regMobileAes(area, mobile, password, |
338 | + shoppingKey, registerCode, null, clientIp, from).then(result => { | ||
335 | if (!result.code || result.code !== 200) { | 339 | if (!result.code || result.code !== 200) { |
336 | return res.send(result); | 340 | return res.send(result); |
337 | } | 341 | } |
@@ -11,6 +11,7 @@ const md5 = require('yoho-md5'); | @@ -11,6 +11,7 @@ const md5 = require('yoho-md5'); | ||
11 | const moment = require('moment'); | 11 | const moment = require('moment'); |
12 | const querystring = require('querystring'); | 12 | const querystring = require('querystring'); |
13 | const thirdAccount = require('../data/third-account.json'); | 13 | const thirdAccount = require('../data/third-account.json'); |
14 | +const FROM = require('../../../config/from'); | ||
14 | 15 | ||
15 | class Auth { | 16 | class Auth { |
16 | 17 | ||
@@ -29,13 +30,14 @@ class Auth { | @@ -29,13 +30,14 @@ class Auth { | ||
29 | return api.post('', param); | 30 | return api.post('', param); |
30 | } | 31 | } |
31 | 32 | ||
32 | - static signinAes(area, profile, password, shoppingKey, ip, isSkip) { | 33 | + static signinAes(area, profile, password, shoppingKey, ip, isSkip, from) { |
33 | let param = { | 34 | let param = { |
34 | method: 'sesame.flowering.higher', | 35 | method: 'sesame.flowering.higher', |
35 | area: area, | 36 | area: area, |
36 | profile: profile, | 37 | profile: profile, |
37 | password: aes.aesPwd(password), | 38 | password: aes.aesPwd(password), |
38 | - isSkip: isSkip ? isSkip : 'N' | 39 | + isSkip: isSkip ? isSkip : 'N', |
40 | + business_line: FROM[from] | ||
39 | }; | 41 | }; |
40 | 42 | ||
41 | if (shoppingKey) { | 43 | if (shoppingKey) { |
1 | /* eslint no-unused-vars: ["error", { "args": "none" }] */ | 1 | /* eslint no-unused-vars: ["error", { "args": "none" }] */ |
2 | 'use strict'; | 2 | 'use strict'; |
3 | const API = global.yoho.API; | 3 | const API = global.yoho.API; |
4 | +const FROM = require('../../../config/from'); | ||
4 | 5 | ||
5 | class PhoneService { | 6 | class PhoneService { |
6 | // 校验 手机 是否 已注册 | 7 | // 校验 手机 是否 已注册 |
@@ -21,7 +22,8 @@ class PhoneService { | @@ -21,7 +22,8 @@ class PhoneService { | ||
21 | profile: param.profile, | 22 | profile: param.profile, |
22 | area: param.area, | 23 | area: param.area, |
23 | code: param.code, | 24 | code: param.code, |
24 | - shopping_key: param.shopping_key | 25 | + shopping_key: param.shopping_key, |
26 | + business_line: FROM[param.from] | ||
25 | }); | 27 | }); |
26 | } | 28 | } |
27 | 29 |
@@ -9,6 +9,7 @@ | @@ -9,6 +9,7 @@ | ||
9 | 9 | ||
10 | const api = global.yoho.API; | 10 | const api = global.yoho.API; |
11 | const aes = require('./aes-pwd'); | 11 | const aes = require('./aes-pwd'); |
12 | +const FROM = require('../../../config/from'); | ||
12 | 13 | ||
13 | const RegService = { | 14 | const RegService = { |
14 | getAreaData() { | 15 | getAreaData() { |
@@ -96,7 +97,7 @@ const RegService = { | @@ -96,7 +97,7 @@ const RegService = { | ||
96 | 97 | ||
97 | return api.post('', params); | 98 | return api.post('', params); |
98 | }, | 99 | }, |
99 | - regMobileAes(area, mobile, password, shoppingKey, smsCode, inviteCode, isFromMy, clientIp) { | 100 | + regMobileAes(area, mobile, password, shoppingKey, smsCode, inviteCode, isFromMy, clientIp, from) { |
100 | isFromMy = isFromMy || '0'; | 101 | isFromMy = isFromMy || '0'; |
101 | 102 | ||
102 | let params = { | 103 | let params = { |
@@ -106,7 +107,8 @@ const RegService = { | @@ -106,7 +107,8 @@ const RegService = { | ||
106 | password: aes.aesPwd(password), | 107 | password: aes.aesPwd(password), |
107 | verifyCode: smsCode, | 108 | verifyCode: smsCode, |
108 | inviteCode: inviteCode, | 109 | inviteCode: inviteCode, |
109 | - isFromMy | 110 | + isFromMy, |
111 | + business_line: FROM[from] | ||
110 | }; | 112 | }; |
111 | 113 | ||
112 | if (shoppingKey) { | 114 | if (shoppingKey) { |
-
Please register or login to post a comment