mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-10-31 21:16:51 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			31 lines
		
	
	
		
			809 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			809 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace Pterodactyl\Http\Middleware\Activity;
 | |
| 
 | |
| use Closure;
 | |
| use Illuminate\Http\Request;
 | |
| use Pterodactyl\Models\ApiKey;
 | |
| use Pterodactyl\Facades\LogTarget;
 | |
| 
 | |
| class TrackAPIKey
 | |
| {
 | |
|     /**
 | |
|      * Determines if the authenticated user making this request is using an actual
 | |
|      * API key, or it is just a cookie authenticated session. This data is set in a
 | |
|      * request singleton so that all tracked activity log events are properly associated
 | |
|      * with the given API key.
 | |
|      *
 | |
|      * @return mixed
 | |
|      */
 | |
|     public function handle(Request $request, Closure $next)
 | |
|     {
 | |
|         if ($request->user()) {
 | |
|             $token = $request->user()->currentAccessToken();
 | |
| 
 | |
|             LogTarget::setApiKeyId($token instanceof ApiKey ? $token->id : null);
 | |
|         }
 | |
| 
 | |
|         return $next($request);
 | |
|     }
 | |
| }
 | 
