egg-passport-weapp
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

egg-passport-weapp

Wechat miniprogram passport plugin for egg.

NPM version Build Status codecov David deps Known Vulnerabilities npm download semantic-release

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
Hardway Hardway Demo

Questions & Suggestions

Please open an issue here.

License

MIT

Test

npm run test-local

Release Notes:

Package Sidebar

Install

npm i egg-passport-weapp

Weekly Downloads

2

Version

1.1.0

License

MIT

Unpacked Size

11.1 kB

Total Files

7

Last publish

Collaborators

  • jeff-tian