Skip to content

Latest commit

 

History

History
92 lines (66 loc) · 2.93 KB

README.md

File metadata and controls

92 lines (66 loc) · 2.93 KB

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: