UNPKG

koa2-boilerplate-plus

Version:
18 lines (16 loc) 421 B
'use strict'; 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 } } } }