Initial commit of the Asset Management System, including project structure, Docker configuration, database migrations, and core application files. Added user authentication, asset management features, and basic UI components.
This commit is contained in:
27
app/Middleware/AdminMiddleware.php
Normal file
27
app/Middleware/AdminMiddleware.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Middleware;
|
||||
|
||||
use App\Core\Request;
|
||||
use App\Core\Response;
|
||||
use App\Core\Session;
|
||||
|
||||
class AdminMiddleware
|
||||
{
|
||||
public function handle(Request $request, Response $response): void
|
||||
{
|
||||
$session = new Session();
|
||||
|
||||
// First check if user is logged in
|
||||
if (!$session->isLoggedIn()) {
|
||||
$session->flash('error', 'Bitte melden Sie sich an, um fortzufahren.');
|
||||
$response->redirect('/login')->send();
|
||||
}
|
||||
|
||||
// Check if user has admin role
|
||||
if (!$session->isAdmin()) {
|
||||
$session->flash('error', 'Sie haben keine Berechtigung für diese Aktion.');
|
||||
$response->redirect('/dashboard')->send();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user