...
|
...
|
@@ -74,6 +74,13 @@ const common = { |
|
|
refer && !/signin|login|passport/.test(refer) && res.cookie('refer', encodeURI(refer), {
|
|
|
domain: 'yohobuy.com'
|
|
|
});
|
|
|
|
|
|
next();
|
|
|
},
|
|
|
weixinCheck: (req, res, next) => {
|
|
|
if (req.yoho.isWechat) {
|
|
|
return res.redirect('/passport/login/wechat');
|
|
|
}
|
|
|
next();
|
|
|
}
|
|
|
};
|
...
|
...
|
@@ -222,6 +229,9 @@ const local = { |
|
|
|
|
|
user.session = refer;
|
|
|
user.href = refer;
|
|
|
res.cookie('_LOGIN_TYPE', 0, {
|
|
|
domain: 'm.yohobuy.com'
|
|
|
});
|
|
|
AuthHelper.syncUserSession(user.uid, req, res, user.session_key).then(() => {
|
|
|
res.json({
|
|
|
code: 200,
|
...
|
...
|
@@ -273,6 +283,15 @@ const wechat = { |
|
|
let nickname = user._json.nickname || user.displayName;
|
|
|
let openId = user._json.unionid || user.id;
|
|
|
|
|
|
res.cookie('_WX_OPENID', _.get(user, '_json.openid'), {
|
|
|
domain: 'm.yohobuy.com'
|
|
|
});
|
|
|
res.cookie('_WX_UNIONID', _.get(user, '_json.unionid'), {
|
|
|
domain: 'm.yohobuy.com'
|
|
|
});
|
|
|
res.cookie('_LOGIN_TYPE', 4, {
|
|
|
domain: 'm.yohobuy.com'
|
|
|
});
|
|
|
doPassportCallback(openId, nickname, 'wechat', req, res).catch(next);
|
|
|
})(req, res, next);
|
|
|
} else {
|
...
|
...
|
@@ -301,6 +320,9 @@ const sina = { |
|
|
let nickname = user.screen_name;
|
|
|
let openId = user.id;
|
|
|
|
|
|
res.cookie('_LOGIN_TYPE', 2, {
|
|
|
domain: 'm.yohobuy.com'
|
|
|
});
|
|
|
doPassportCallback(openId, nickname, 'sina', req, res).catch(next);
|
|
|
})(req, res, next);
|
|
|
} else {
|
...
|
...
|
@@ -330,6 +352,9 @@ const qq = { |
|
|
let nickname = user.nickname;
|
|
|
let openId = user.id;
|
|
|
|
|
|
res.cookie('_LOGIN_TYPE', 1, {
|
|
|
domain: 'm.yohobuy.com'
|
|
|
});
|
|
|
doPassportCallback(openId, nickname, 'qq', req, res).catch(next);
|
|
|
})(req, res, next);
|
|
|
} else {
|
...
|
...
|
@@ -354,6 +379,9 @@ const alipay = { |
|
|
let nickname = user.realName;
|
|
|
let openId = user.userId;
|
|
|
|
|
|
res.cookie('_LOGIN_TYPE', 3, {
|
|
|
domain: 'm.yohobuy.com'
|
|
|
});
|
|
|
doPassportCallback(openId, nickname, 'alipay', req, res).catch(next);
|
|
|
})(req, res, next);
|
|
|
}
|
...
|
...
|
|