Authored by 周少峰

Merge branch 'hotfix/login_qq' into release/1019

... ... @@ -33,38 +33,33 @@ function doPassportCallback(req, res, user) {
refer = config.siteUrl;
}
if (user.openId) {
let signinByOpenID;
user.nickname = _.trim(user.nickname);
if (user.sourceType === 'wechat') {
// PC 的微信登录之前使用了 open_id, 所以需要特别的接口处理
signinByOpenID = AuthHelper.signinByWechat(
user.nickname, user.openId, user.unionId, user.sourceType, shoppingKey);
} else {
signinByOpenID = AuthHelper.signinByOpenID(
user.nickname, user.openId, user.sourceType, shoppingKey);
// PC 的微信登录使用unionId
user.openId = user.unionId;
}
return signinByOpenID.then((result) => {
if (result.code !== 200) {
return Promise.reject(result);
}
if (result.data['is_bind'] && result.data['is_bind'] === 'N') { //eslint-disable-line
return helpers.urlFormat('/passport/thirdlogin/index', {
openId: user.unionId || user.openId,
sourceType: user.sourceType,
refer: refer
});
} else if (result.code === 200 && result.data.uid) {
return AuthHelper.syncUserSession(result.data.uid, req, res).then(() => {
return refer;
});
}
}).then((redirectTo) => {
return res.redirect(redirectTo);
});
return AuthHelper.signinByOpenID(user.nickname, user.openId, user.sourceType, shoppingKey)
.then((result) => {
if (result.code !== 200) {
return res.redirect(config.siteUrl);
}
if (result.data['is_bind'] && result.data['is_bind'] === 'N') { //eslint-disable-line
return helpers.urlFormat('/passport/thirdlogin/index', {
openId: user.unionId || user.openId,
sourceType: user.sourceType,
refer: refer
});
} else if (result.code === 200 && result.data.uid) {
return AuthHelper.syncUserSession(result.data.uid, req, res).then(() => {
return refer;
});
}
})
.then((redirectTo) => {
return res.redirect(redirectTo);
});
} else {
return Promise.resolve(res.redirect(loginPage));
}
... ...