ChengLei Shao 5df11c58c7
fix: 204 no content response (#378)
* fix: 204 no content response

* Update data-wrapping.ts

* Update plugin.ts

Co-authored-by: chenos <chenlinxh@gmail.com>
2022-05-22 14:48:50 +08:00

12 lines
345 B
TypeScript

// TODO(usage): 拦截用户的处理暂时作为一个中间件导出,应用需要的时候可以直接使用这个中间件
export function check(options) {
return async function check(ctx, next) {
const { currentUser } = ctx.state;
if (!currentUser) {
return ctx.throw(401, 'Unauthorized');
}
return next();
};
}