Improved CP error handling and audit log

This commit is contained in:
Pinga 2025-03-31 13:00:34 +03:00
parent 0c6cb72852
commit 18e6eafb41
5 changed files with 113 additions and 3 deletions

View file

@ -0,0 +1,22 @@
<?php
namespace App\Middleware;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Server\RequestHandlerInterface as RequestHandler;
use Pinga\Session;
class AuditMiddleware extends Middleware
{
public function __invoke(Request $request, RequestHandler $handler)
{
if (isset($_SESSION['auth_user_id'])) {
$userId = (int)$_SESSION['auth_user_id'];
$this->container->get('db')->exec("SET @audit_usr_id = $userId");
$this->container->get('db')->exec("SET @audit_ses_id = " . crc32(\Pinga\Session\Session::id()));
}
return $handler->handle($request);
}
}