egg-full-jwt
Chinese 中文
Important
jsonwebtoken@8.4.0
Install
$ npm i egg-full-jwt --save
Usage
// {app_root}/config/plugin.jsexportsfullJwt = enable: true package: 'egg-full-jwt';
Configuration
// {app_root}/config/config.default.jsexportsfullJwt = secret: 'your key' exp: 'expire time' // default 3600 seconds;
see config/config.default.js for more detail.
Example
'use strict'; module { Controller // /login?userId=10001 async { // password check ... const userId = thisctxquery; const token = await appfullJwt; // cookies thisctxcookies; thisctxbody = 'login success'; } async { const token = thisctxcookies; if token === false thisctx; const userId = await appfullJwt; if userId thisctx; thisctxbody = 'hello World'; } return HomeController;};