koa-passport-example
koa-passport-example copied to clipboard
[question] function based authentication route
// Require authentication for now
app.use(function(ctx, next) {
if (ctx.isAuthenticated()) {
return next()
} else {
ctx.redirect('/')
}
})
is there a way to require authentication per route ? like this:
app.use(isAuthenticated(), async ctx => { ctx.body = 'this is restricted'; })