mirror of
https://github.com/linuxserver/Heimdall.git
synced 2026-02-22 12:40:32 +09:00
Initial start of adding an API
This commit is contained in:
30
app/Http/Middleware/UserApiKey.php
Normal file
30
app/Http/Middleware/UserApiKey.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use \App\SettingUser;
|
||||
|
||||
class UserApiKey
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$key = $request->input('api_key');
|
||||
$details = SettingUser::where('setting_id', 12)->where('uservalue', $key)->first();
|
||||
// die(var_dump($details));
|
||||
if($details === null) {
|
||||
return response()->json([
|
||||
'status' => 401,
|
||||
'message' => 'invalid api key'
|
||||
], 401);
|
||||
}
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user