Authored by 周少峰

Merge branch 'hotfix/login_qq' into release/1019

@@ -33,38 +33,33 @@ function doPassportCallback(req, res, user) { @@ -33,38 +33,33 @@ function doPassportCallback(req, res, user) {
33 refer = config.siteUrl; 33 refer = config.siteUrl;
34 } 34 }
35 if (user.openId) { 35 if (user.openId) {
36 - let signinByOpenID;  
37 -  
38 user.nickname = _.trim(user.nickname); 36 user.nickname = _.trim(user.nickname);
39 37
40 if (user.sourceType === 'wechat') { 38 if (user.sourceType === 'wechat') {
41 -  
42 - // PC 的微信登录之前使用了 open_id, 所以需要特别的接口处理  
43 - signinByOpenID = AuthHelper.signinByWechat(  
44 - user.nickname, user.openId, user.unionId, user.sourceType, shoppingKey);  
45 - } else {  
46 - signinByOpenID = AuthHelper.signinByOpenID(  
47 - user.nickname, user.openId, user.sourceType, shoppingKey); 39 + // PC 的微信登录使用unionId
  40 + user.openId = user.unionId;
48 } 41 }
49 42
50 - return signinByOpenID.then((result) => {  
51 - if (result.code !== 200) {  
52 - return Promise.reject(result);  
53 - }  
54 - if (result.data['is_bind'] && result.data['is_bind'] === 'N') { //eslint-disable-line  
55 - return helpers.urlFormat('/passport/thirdlogin/index', {  
56 - openId: user.unionId || user.openId,  
57 - sourceType: user.sourceType,  
58 - refer: refer  
59 - });  
60 - } else if (result.code === 200 && result.data.uid) {  
61 - return AuthHelper.syncUserSession(result.data.uid, req, res).then(() => {  
62 - return refer;  
63 - });  
64 - }  
65 - }).then((redirectTo) => {  
66 - return res.redirect(redirectTo);  
67 - }); 43 + return AuthHelper.signinByOpenID(user.nickname, user.openId, user.sourceType, shoppingKey)
  44 + .then((result) => {
  45 + if (result.code !== 200) {
  46 + return res.redirect(config.siteUrl);
  47 + }
  48 + if (result.data['is_bind'] && result.data['is_bind'] === 'N') { //eslint-disable-line
  49 + return helpers.urlFormat('/passport/thirdlogin/index', {
  50 + openId: user.unionId || user.openId,
  51 + sourceType: user.sourceType,
  52 + refer: refer
  53 + });
  54 + } else if (result.code === 200 && result.data.uid) {
  55 + return AuthHelper.syncUserSession(result.data.uid, req, res).then(() => {
  56 + return refer;
  57 + });
  58 + }
  59 + })
  60 + .then((redirectTo) => {
  61 + return res.redirect(redirectTo);
  62 + });
68 } else { 63 } else {
69 return Promise.resolve(res.redirect(loginPage)); 64 return Promise.resolve(res.redirect(loginPage));
70 } 65 }