forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServerSubject.php
More file actions
29 lines (25 loc) · 883 Bytes
/
ServerSubject.php
File metadata and controls
29 lines (25 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
namespace Pterodactyl\Http\Middleware\Activity;
use Illuminate\Http\Request;
use Pterodactyl\Models\Server;
use Pterodactyl\Facades\LogTarget;
class ServerSubject
{
/**
* 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);
}
}