Add new activity logging code to replace audit log
This commit is contained in:
parent
c14c7b436e
commit
5bb66a00d8
11 changed files with 534 additions and 0 deletions
30
app/Http/Middleware/ServerActivityLogs.php
Normal file
30
app/Http/Middleware/ServerActivityLogs.php
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Facades\LogTarget;
|
||||
|
||||
class ServerActivityLogs
|
||||
{
|
||||
/**
|
||||
* Attempts to automatically scope all of the activity log events registered
|
||||
* within the request instance to the given user and server. This only sets
|
||||
* the actor and subject if there is a server present on the request.
|
||||
*
|
||||
* If no server is found this is a no-op as the activity log service can always
|
||||
* set the user based on the authmanager response.
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
$server = $request->route()->parameter('server');
|
||||
if ($server instanceof Server) {
|
||||
LogTarget::setActor($request->user());
|
||||
LogTarget::setSubject($server);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue