mirror of
https://github.com/YMFE/yapi.git
synced 2024-12-21 05:19:42 +08:00
18 lines
570 B
JavaScript
18 lines
570 B
JavaScript
const jwt = require('jsonwebtoken');
|
||
//检查token是否过期
|
||
|
||
module.exports = async ( ctx, next ) => {
|
||
// const authorization = ctx.get('Authorization');
|
||
// if (authorization === '') {
|
||
// ctx.throw(401, 'no token detected in http header ');
|
||
// }
|
||
// const token = authorization.split(' ')[1];
|
||
// let tokenContent;
|
||
// try {
|
||
// tokenContent = await jwt.verify(token, 'qunar'); //如果token过期或验证失败,将抛出错误
|
||
// } catch (err) {
|
||
// ctx.throw(401, 'invalid token');
|
||
// }
|
||
await next();
|
||
}
|