stuff
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import type { HttpContext } from '@adonisjs/core/http'
|
||||
import type { NextFn } from '@adonisjs/core/types/http'
|
||||
|
||||
export default class AdminMiddleware {
|
||||
async handle(ctx: HttpContext, next: NextFn) {
|
||||
const user = ctx.auth.user
|
||||
|
||||
if (!user || user.role !== 'admin') {
|
||||
return ctx.response.forbidden({ message: 'Access denied. Administrators only.' })
|
||||
}
|
||||
|
||||
return next()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user