egg-passport-weapp
v1.1.0
Published
Wechat mini program passport plugin for egg
Downloads
7
Maintainers
Readme
egg-passport-weapp
Wechat miniprogram passport plugin for egg.
Example
Open https://uniheart.herokuapp.com/ to see the result.
Install
$ npm i egg-passport-weapp --save
Usage
// {app_root}/config/plugin.[t|j]s
exports.passportWeapp = {
enable: true,
package: "egg-passport-weapp"
};
Configuration
// {app_root}/config/config.default.[t|j]s
exports.passportWeapp = {
key: "your oauth key",
secret: "your oauth secret"
};
// {app_root}/app/router.js
app.passport.mount("weapp", app.config.passportWeapp);
router.get("/passport/weapp/callback", ctx => {
// Now get you get ctx.user, write your login logic here,
// for example, write session
ctx.session.userId = ctx.user.id;
// And then return something instead of redirect
ctx.body = ctx.user;
});
see config/config.default.ts for more detail.
Example
| Wechat Mini Program | Wechat Mini Program Demo version | | :---------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------: | | | |
Questions & Suggestions
Please open an issue here.
License
Test
npm run test-local