加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
app.js 898 Bytes
一键复制 编辑 原始数据 按行查看 历史
chenjiyong 提交于 2019-05-09 14:43 . 提交
'use strict';
const debug = require('debug')('egg-passport-wechat');
const assert = require('assert');
const WechatStrategy = require('passport-weixin');
module.exports = app => {
const config = app.config.passportWechat;
config.passReqToCallback = true;
assert(config.clientID, '[egg-passport-wechat] config.passportWechat.clientID required');
assert(config.clientSecret, '[egg-passport-wechat] config.passportWechat.clientSecret required');
// must require `req` params
app.passport.use(
'wechat',
new WechatStrategy(
config,
(req, token, tokenSecret, params, profile, done) => {
// format user
const user = profile._json
user.provider = 'wechat'
debug('%s %s get user: %j', req.method, req.url, user);
// let passport do verify and call verify hook
app.passport.doVerify(req, user, done);
}
)
);
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化