koa2-boilerplate-plus
Version:
Enhanced koa2 boilerplate
18 lines (16 loc) • 421 B
JavaScript
;
export default function checkauth() {
return async function (ctx, next) {
if (ctx.isAuthenticated()
|| ctx.path.indexOf('/auth/') >= 0
|| ctx.path.indexOf('/open/') >= 0
|| ctx.path==='/'
|| ctx.path.indexOf('.html') >= 0) {
await next()
} else {
ctx.body = {
"status" : 401
}
}
}
}