mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-09 15:05:35 +00:00
feat: add basic admin dashboard
This commit is contained in:
11
app/middleware/admin_middleware.ts
Normal file
11
app/middleware/admin_middleware.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
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) {
|
||||
if (!ctx.auth.user?.isAdmin) {
|
||||
return ctx.response.redirectToNamedRoute('dashboard');
|
||||
}
|
||||
return next();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user