|
@@ -27,18 +27,20 @@ function doPassportCallback(openId, nickname, req, res) { |
|
@@ -27,18 +27,20 @@ function doPassportCallback(openId, nickname, req, res) { |
27
|
if (openId && nickname) {
|
27
|
if (openId && nickname) {
|
28
|
AuthHelper.signinByOpenID(nickname, openId, 'wechat', shoppingKey).then((result) => {
|
28
|
AuthHelper.signinByOpenID(nickname, openId, 'wechat', shoppingKey).then((result) => {
|
29
|
if (result.data['is_bind'] && result.data['is_bind'] === 'N') { //eslint-disable-line
|
29
|
if (result.data['is_bind'] && result.data['is_bind'] === 'N') { //eslint-disable-line
|
30
|
- res.redirect(helpers.urlFormat('/passport/bind/index', {
|
30
|
+ return helpers.urlFormat('/passport/bind/index', {
|
31
|
openId: openId,
|
31
|
openId: openId,
|
32
|
sourceType: 'wechat'
|
32
|
sourceType: 'wechat'
|
33
|
- }));
|
33
|
+ });
|
34
|
} else if (result.code === 200 && result.data.uid) {
|
34
|
} else if (result.code === 200 && result.data.uid) {
|
35
|
- return AuthHelper.syncUserSession(result.data.uid, res);
|
35
|
+ return AuthHelper.syncUserSession(result.data.uid, res).then(() => {
|
|
|
36
|
+ return refer;
|
|
|
37
|
+ });
|
36
|
}
|
38
|
}
|
37
|
- }).then(() => {
|
|
|
38
|
- res.redirect(refer);
|
39
|
+ }).then((redirectTo) => {
|
|
|
40
|
+ return res.redirect(redirectTo);
|
39
|
}).catch((e) => {
|
41
|
}).catch((e) => {
|
40
|
log.error('频道页面渲染错误:' + JSON.stringify(e));
|
42
|
log.error('频道页面渲染错误:' + JSON.stringify(e));
|
41
|
- res.send('error');
|
43
|
+ return res.send('error');
|
42
|
});
|
44
|
});
|
43
|
}
|
45
|
}
|
44
|
}
|
46
|
}
|
|
@@ -58,7 +60,6 @@ const wechat = { |
|
@@ -58,7 +60,6 @@ const wechat = { |
58
|
if (err) {
|
60
|
if (err) {
|
59
|
return next(err);
|
61
|
return next(err);
|
60
|
}
|
62
|
}
|
61
|
- console.log(user);
|
|
|
62
|
let nickname = user.displayName || user._json.nickname;
|
63
|
let nickname = user.displayName || user._json.nickname;
|
63
|
let openId = user.id || user._json.unionid;
|
64
|
let openId = user.id || user._json.unionid;
|
64
|
|
65
|
|