...
|
...
|
@@ -7,6 +7,7 @@ |
|
|
|
|
|
const library = '../../../library';
|
|
|
const passport = require('passport');
|
|
|
const uuid = require('uuid');
|
|
|
const cookie = require(`${library}/cookie`);
|
|
|
const helpers = require(`${library}/helpers`);
|
|
|
const log = require(`${library}/logger`);
|
...
|
...
|
@@ -42,7 +43,6 @@ function doPassportCallback(openId, nickname, sourceType, req, res) { |
|
|
});
|
|
|
}
|
|
|
}).then((redirectTo) => {
|
|
|
console.log('redirectTo=', redirectTo);
|
|
|
return res.redirect(redirectTo);
|
|
|
}).catch((e) => {
|
|
|
log.error('频道页面渲染错误:' + JSON.stringify(e));
|
...
|
...
|
@@ -64,7 +64,10 @@ const wechat = { |
|
|
next();
|
|
|
},
|
|
|
login: (req, res, next) => {
|
|
|
return passport.authenticate('weixin')(req, res, next);
|
|
|
console.log('1');
|
|
|
return passport.authenticate('weixin', {
|
|
|
state: uuid.v4()
|
|
|
})(req, res, next);
|
|
|
},
|
|
|
callback: (req, res, next) => {
|
|
|
passport.authenticate('weixin', (err, user) => {
|
...
|
...
|
@@ -72,8 +75,9 @@ const wechat = { |
|
|
log.error(`wechat authenticate error : ${JSON.stringify(err)}`);
|
|
|
return res.redirect(loginPage);
|
|
|
}
|
|
|
let nickname = user.displayName || user._json.nickname;
|
|
|
let openId = user.id || user._json.unionid;
|
|
|
console.log(user);
|
|
|
let nickname = user._json.nickname || user.displayName;
|
|
|
let openId = user._json.unionid || user.id;
|
|
|
|
|
|
doPassportCallback(openId, nickname, 'wechat', req, res);
|
|
|
})(req, res, next);
|
...
|
...
|
|