Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/app/Http/Middleware/Activity/ServerSubject.php
10279 views
1
<?php
2
3
namespace Pterodactyl\Http\Middleware\Activity;
4
5
use Illuminate\Http\Request;
6
use Pterodactyl\Models\Server;
7
use Pterodactyl\Facades\LogTarget;
8
9
class ServerSubject
10
{
11
/**
12
* Attempts to automatically scope all of the activity log events registered
13
* within the request instance to the given user and server. This only sets
14
* the actor and subject if there is a server present on the request.
15
*
16
* If no server is found this is a no-op as the activity log service can always
17
* set the user based on the authmanager response.
18
*/
19
public function handle(Request $request, \Closure $next)
20
{
21
$server = $request->route()->parameter('server');
22
if ($server instanceof Server) {
23
LogTarget::setActor($request->user());
24
LogTarget::setSubject($server);
25
}
26
27
return $next($request);
28
}
29
}
30
31