Showing
6 changed files
with
47 additions
and
12 deletions
@@ -80,7 +80,7 @@ passport.use('local', new LocalStrategy({ | @@ -80,7 +80,7 @@ passport.use('local', new LocalStrategy({ | ||
80 | } | 80 | } |
81 | }; | 81 | }; |
82 | 82 | ||
83 | - done(null, {uid}); | 83 | + done(null, {uid, session_key: result.data.session_key}); |
84 | } else { | 84 | } else { |
85 | errLoginTimes = errLoginTimes + 1; | 85 | errLoginTimes = errLoginTimes + 1; |
86 | accountTimes = accountTimes + 1; | 86 | accountTimes = accountTimes + 1; |
@@ -212,7 +212,18 @@ const bind = { | @@ -212,7 +212,18 @@ const bind = { | ||
212 | sourceType: sourceType + '_bind' | 212 | sourceType: sourceType + '_bind' |
213 | }); | 213 | }); |
214 | 214 | ||
215 | - return loginService.syncUserSession(result.data.uid, req, res).then(() => { | 215 | + let uid = { |
216 | + toString() { | ||
217 | + return this.uid; | ||
218 | + }, | ||
219 | + uid: result.data.uid, | ||
220 | + sessionKey: result.data.session_key, | ||
221 | + isValid() { | ||
222 | + return this.uid && this.sessionKey; | ||
223 | + } | ||
224 | + }; | ||
225 | + | ||
226 | + return loginService.syncUserSession(uid, req, res, result.data.session_key).then(() => { | ||
216 | return {code: 200, message: result.message, data: {refer: refer}}; | 227 | return {code: 200, message: result.message, data: {refer: refer}}; |
217 | }); | 228 | }); |
218 | } else { | 229 | } else { |
@@ -246,7 +257,18 @@ const bind = { | @@ -246,7 +257,18 @@ const bind = { | ||
246 | sourceType: sourceType + '_relate' | 257 | sourceType: sourceType + '_relate' |
247 | }); | 258 | }); |
248 | 259 | ||
249 | - return loginService.syncUserSession(result.data.uid, req, res).then(() => { | 260 | + let uid = { |
261 | + toString() { | ||
262 | + return this.uid; | ||
263 | + }, | ||
264 | + uid: result.data.uid, | ||
265 | + sessionKey: result.data.session_key, | ||
266 | + isValid() { | ||
267 | + return this.uid && this.sessionKey; | ||
268 | + } | ||
269 | + }; | ||
270 | + | ||
271 | + return loginService.syncUserSession(uid, req, res, result.data.session_key).then(() => { | ||
250 | return {code: 200, message: result.message, data: {refer: refer}}; | 272 | return {code: 200, message: result.message, data: {refer: refer}}; |
251 | }); | 273 | }); |
252 | } else { | 274 | } else { |
@@ -273,7 +273,18 @@ let mobileRegister = (req, res, next) => { | @@ -273,7 +273,18 @@ let mobileRegister = (req, res, next) => { | ||
273 | return res.json(data); | 273 | return res.json(data); |
274 | } | 274 | } |
275 | 275 | ||
276 | - return loginService.syncUserSession(regResult.data.uid, req, res).then(() => { | 276 | + let uid = { |
277 | + toString() { | ||
278 | + return this.uid; | ||
279 | + }, | ||
280 | + uid: result.data.uid, | ||
281 | + sessionKey: result.data.session_key, | ||
282 | + isValid() { | ||
283 | + return this.uid && this.sessionKey; | ||
284 | + } | ||
285 | + }; | ||
286 | + | ||
287 | + return loginService.syncUserSession(uid, req, res, regResult.data.session_key).then(() => { | ||
277 | return res.json({ | 288 | return res.json({ |
278 | code: 200, | 289 | code: 200, |
279 | message: '注册成功', | 290 | message: '注册成功', |
@@ -62,6 +62,7 @@ const syncUserSession = (uid, req, res, sessionKey) => { | @@ -62,6 +62,7 @@ const syncUserSession = (uid, req, res, sessionKey) => { | ||
62 | res.cookie('isStudent', isStudent, { | 62 | res.cookie('isStudent', isStudent, { |
63 | domain: config.cookieDomain | 63 | domain: config.cookieDomain |
64 | }); | 64 | }); |
65 | + | ||
65 | res.cookie('_SESSION_KEY', authcode(sessionKey, '_SESSION_KEY', AUTH_TIME, 'encode'), { | 66 | res.cookie('_SESSION_KEY', authcode(sessionKey, '_SESSION_KEY', AUTH_TIME, 'encode'), { |
66 | domain: config.cookieDomain | 67 | domain: config.cookieDomain |
67 | }); | 68 | }); |
@@ -17,14 +17,14 @@ module.exports = { | @@ -17,14 +17,14 @@ module.exports = { | ||
17 | cookieDomain: '.yohobuy.com', | 17 | cookieDomain: '.yohobuy.com', |
18 | domains: { | 18 | domains: { |
19 | // test3 | 19 | // test3 |
20 | - // singleApi: 'http://api-test3.yohops.com:9999/', | ||
21 | - // api: 'http://api-test3.yohops.com:9999/', | ||
22 | - // service: 'http://service-test3.yohops.com:9999/', | 20 | + singleApi: 'http://api-test3.yohops.com:9999/', |
21 | + api: 'http://api-test3.yohops.com:9999/', | ||
22 | + service: 'http://service-test3.yohops.com:9999/', | ||
23 | 23 | ||
24 | // prod | 24 | // prod |
25 | - singleApi: 'http://single.yoho.cn/', | ||
26 | - api: 'http://api.yoho.cn/', | ||
27 | - service: 'http://service.yoho.cn/', | 25 | + //singleApi: 'http://single.yoho.cn/', |
26 | + //api: 'http://api.yoho.cn/', | ||
27 | + //service: 'http://service.yoho.cn/', | ||
28 | 28 | ||
29 | // gray | 29 | // gray |
30 | // singleApi: 'http://single.gray.yohops.com/', | 30 | // singleApi: 'http://single.gray.yohops.com/', |
@@ -9,7 +9,7 @@ const authcode = require(`${global.utils}/authcode`); | @@ -9,7 +9,7 @@ const authcode = require(`${global.utils}/authcode`); | ||
9 | // const cache = global.yoho.cache; | 9 | // const cache = global.yoho.cache; |
10 | 10 | ||
11 | function decrypt(word) { | 11 | function decrypt(word) { |
12 | - return authcode(word, '_SESSION_KEY'); | 12 | + return authcode(word, '_SESSION_KEY', 0, 'decode'); |
13 | } | 13 | } |
14 | 14 | ||
15 | module.exports = () => { | 15 | module.exports = () => { |
@@ -37,11 +37,12 @@ module.exports = () => { | @@ -37,11 +37,12 @@ module.exports = () => { | ||
37 | return this.uid; | 37 | return this.uid; |
38 | }, | 38 | }, |
39 | uid: cookie.getUid(req), | 39 | uid: cookie.getUid(req), |
40 | - sessionKey: decrypt(req.cookies._SESSION_KEY), | 40 | + sessionKey: decodeURIComponent(decrypt(req.cookies._SESSION_KEY)), |
41 | isValid() { | 41 | isValid() { |
42 | return this.uid && this.sessionKey; | 42 | return this.uid && this.sessionKey; |
43 | } | 43 | } |
44 | }; | 44 | }; |
45 | + | ||
45 | } | 46 | } |
46 | 47 | ||
47 | // 记住我 | 48 | // 记住我 |
-
Please register or login to post a comment