Authored by htoooth

fix error

@@ -69,18 +69,7 @@ passport.use('local', new LocalStrategy({ @@ -69,18 +69,7 @@ passport.use('local', new LocalStrategy({
69 if (result.code && result.code === 200 && result.data.uid) { 69 if (result.code && result.code === 200 && result.data.uid) {
70 cache.del(errorLoginKey).catch(() => {}); 70 cache.del(errorLoginKey).catch(() => {});
71 71
72 - let uid = {  
73 - toString() {  
74 - return this.uid;  
75 - },  
76 - uid: result.data.uid,  
77 - sessionKey: result.data.session_key,  
78 - isValid() {  
79 - return this.uid && this.sessionKey;  
80 - }  
81 - };  
82 -  
83 - done(null, {uid, session_key: result.data.session_key}); 72 + done(null, result.data);
84 } else { 73 } else {
85 errLoginTimes = errLoginTimes + 1; 74 errLoginTimes = errLoginTimes + 1;
86 accountTimes = accountTimes + 1; 75 accountTimes = accountTimes + 1;
@@ -212,18 +212,7 @@ const bind = { @@ -212,18 +212,7 @@ const bind = {
212 sourceType: sourceType + '_bind' 212 sourceType: sourceType + '_bind'
213 }); 213 });
214 214
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(() => { 215 + return loginService.syncUserSession(result.data.uid, req, res, result.data.session_key).then(() => {
227 return {code: 200, message: result.message, data: {refer: refer}}; 216 return {code: 200, message: result.message, data: {refer: refer}};
228 }); 217 });
229 } else { 218 } else {
@@ -257,18 +246,7 @@ const bind = { @@ -257,18 +246,7 @@ const bind = {
257 sourceType: sourceType + '_relate' 246 sourceType: sourceType + '_relate'
258 }); 247 });
259 248
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(() => { 249 + return loginService.syncUserSession(result.data.uid, req, res, result.data.session_key).then(() => {
272 return {code: 200, message: result.message, data: {refer: refer}}; 250 return {code: 200, message: result.message, data: {refer: refer}};
273 }); 251 });
274 } else { 252 } else {
@@ -67,18 +67,7 @@ function doPassportCallback(req, res, user) { @@ -67,18 +67,7 @@ function doPassportCallback(req, res, user) {
67 }); 67 });
68 } else if (result.data['is_bind'] === 'Y' && result.data.uid) {//eslint-disable-line 68 } else if (result.data['is_bind'] === 'Y' && result.data.uid) {//eslint-disable-line
69 69
70 - let uid = {  
71 - toString() {  
72 - return this.uid;  
73 - },  
74 - uid: result.data.uid,  
75 - sessionKey: result.data.session_key,  
76 - isValid() {  
77 - return this.uid && this.sessionKey;  
78 - }  
79 - };  
80 -  
81 - return loginService.syncUserSession(uid, req, res, result.data.session_key).then(() => { 70 + return loginService.syncUserSession(result.data.uid, req, res, result.data.session_key).then(() => {
82 return refer; 71 return refer;
83 }); 72 });
84 } 73 }
@@ -273,18 +273,7 @@ let mobileRegister = (req, res, next) => { @@ -273,18 +273,7 @@ let mobileRegister = (req, res, next) => {
273 return res.json(data); 273 return res.json(data);
274 } 274 }
275 275
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(() => { 276 + return loginService.syncUserSession(regResult.data.uid, req, res, regResult.data.session_key).then(() => {
288 return res.json({ 277 return res.json({
289 code: 200, 278 code: 200,
290 message: '注册成功', 279 message: '注册成功',
@@ -37,10 +37,21 @@ const syncUserSession = (uid, req, res, sessionKey) => { @@ -37,10 +37,21 @@ const syncUserSession = (uid, req, res, sessionKey) => {
37 }); 37 });
38 } 38 }
39 39
  40 + let uidObj = {
  41 + toString() {
  42 + return this.uid;
  43 + },
  44 + uid: uid,
  45 + sessionKey: sessionKey,
  46 + isValid() {
  47 + return this.uid && this.sessionKey;
  48 + }
  49 + };
  50 +
40 return Promise.all([ 51 return Promise.all([
41 - userService.profile(uid),  
42 - cartService.goodsCount(uid),  
43 - userService.checkNoCertEmailUser(uid).catch(err => logger(`checkNoCertEmailUser${uid}err: ${err}`)) 52 + userService.profile(uidObj),
  53 + cartService.goodsCount(uidObj),
  54 + userService.checkNoCertEmailUser(uidObj).catch(err => logger(`checkNoCertEmailUser${uid}err: ${err}`))
44 ]).spread((userInfo, count, isTipCert) => { 55 ]).spread((userInfo, count, isTipCert) => {
45 let salt = uuid.v4().substr(0, 8); 56 let salt = uuid.v4().substr(0, 8);
46 let saltedUid = uid + salt; 57 let saltedUid = uid + salt;