Authored by 姜枫

fix session key

@@ -53,7 +53,7 @@ function doPassportCallback(req, res, user) { @@ -53,7 +53,7 @@ function doPassportCallback(req, res, user) {
53 refer: refer 53 refer: refer
54 }); 54 });
55 } else if (result.data['is_bind'] === 'Y' && result.data.uid) {//eslint-disable-line 55 } else if (result.data['is_bind'] === 'Y' && result.data.uid) {//eslint-disable-line
56 - return loginService.syncUserSession(result.data.uid, result.data.session_key, req, res).then(() => { 56 + return loginService.syncUserSession(result.data.uid, req, res, result.data.session_key).then(() => {
57 return refer; 57 return refer;
58 }); 58 });
59 } 59 }
@@ -178,7 +178,7 @@ const local = { @@ -178,7 +178,7 @@ const local = {
178 } 178 }
179 }()); 179 }());
180 180
181 - loginService.syncUserSession(user.uid, user.session_key, req, res).then(() => { 181 + loginService.syncUserSession(user.uid, req, res, user.session_key).then(() => {
182 return res.json({ 182 return res.json({
183 code: 200, 183 code: 200,
184 data: { 184 data: {
@@ -24,10 +24,12 @@ const signin = (type, area, profile, password, shoppingKey) => { @@ -24,10 +24,12 @@ const signin = (type, area, profile, password, shoppingKey) => {
24 return loginBy[type](area, profile, password, shoppingKey); 24 return loginBy[type](area, profile, password, shoppingKey);
25 }; 25 };
26 26
27 -const syncUserSession = (uid, sessionKey, req, res) => {  
28 - cache.set(`java_session_key:${uid}`, sessionKey).catch(() => {  
29 - global.yoho.logger.error('write session key fail');  
30 - }); 27 +const syncUserSession = (uid, req, res, sessionKey) => {
  28 + if (sessionKey) {
  29 + cache.set(`java_session_key:${uid}`, sessionKey).catch(() => {
  30 + global.yoho.logger.error('write session key fail');
  31 + });
  32 + }
31 33
32 return Promise.all([userService.profile(uid), cartService.goodsCount(uid)]).spread((userInfo, count) => { 34 return Promise.all([userService.profile(uid), cartService.goodsCount(uid)]).spread((userInfo, count) => {
33 let token = sign.makeToken(uid); 35 let token = sign.makeToken(uid);
@@ -24,7 +24,7 @@ module.exports = () => { @@ -24,7 +24,7 @@ module.exports = () => {
24 }); 24 });
25 res.removeHeader('Pragma'); 25 res.removeHeader('Pragma');
26 res.removeHeader('Expires'); 26 res.removeHeader('Expires');
27 - } else if (req.get('X-Requested-With') === 'XMLHttpRequest') { 27 + } else if (req.xhr) {
28 res.set('Cache-Control', 'no-cache'); 28 res.set('Cache-Control', 'no-cache');
29 } else { 29 } else {
30 res.set({ 30 res.set({
@@ -63,7 +63,7 @@ @@ -63,7 +63,7 @@
63 "uuid": "^2.0.2", 63 "uuid": "^2.0.2",
64 "winston": "^2.2.0", 64 "winston": "^2.2.0",
65 "winston-daily-rotate-file": "^1.1.4", 65 "winston-daily-rotate-file": "^1.1.4",
66 - "yoho-node-lib": "0.1.26", 66 + "yoho-node-lib": "0.1.27",
67 "yoho-zookeeper": "^1.0.3" 67 "yoho-zookeeper": "^1.0.3"
68 }, 68 },
69 "devDependencies": { 69 "devDependencies": {