Spaces:
Running
Running
Download app/Http/Middleware/CheckJobOwnership.php from Ailixir-AI-Team/ailixir-api: direct link, hf CLI and curl.
- Browser
- Download file 866 Bytes
-
https://huggingface.co/spaces/Ailixir-AI-Team/ailixir-api/resolve/06e8928c07068b151bcea9d64ac2b8b28c9090ff/app/Http/Middleware/CheckJobOwnership.php
- Command line
-
hf download hf://spaces/Ailixir-AI-Team/ailixir-api@06e8928c07068b151bcea9d64ac2b8b28c9090ff/app/Http/Middleware/CheckJobOwnership.php
-
curl -L -o CheckJobOwnership.php https://huggingface.co/spaces/Ailixir-AI-Team/ailixir-api/resolve/06e8928c07068b151bcea9d64ac2b8b28c9090ff/app/Http/Middleware/CheckJobOwnership.php
866 Bytes
| namespace App\Http\Middleware; | |
| use Closure; | |
| use Illuminate\Http\Request; | |
| use App\Models\AiJob; | |
| use Illuminate\Support\Facades\Auth; | |
| class CheckJobOwnership | |
| { | |
| public function handle(Request $request, Closure $next) | |
| { | |
| $jobId = $request->route('job_id'); | |
| if (!$jobId) { | |
| return response()->json([ | |
| 'success' => false, | |
| 'message' => 'Job ID is required' | |
| ], 400); | |
| } | |
| $aiJob = AiJob::where('job_id', $jobId) | |
| ->where('user_id', Auth::id()) | |
| ->first(); | |
| if (!$aiJob) { | |
| return response()->json([ | |
| 'success' => false, | |
| 'message' => 'You do not have permission to access this job' | |
| ], 403); | |
| } | |
| $request->merge(['ai_job' => $aiJob]); | |
| return $next($request); | |
| } | |
| } | |