Added logging to API calls
This commit is contained in:
parent
f62ea9669b
commit
9baa249ba7
|
@ -9,6 +9,7 @@ use Closure;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class APIAuthenticationMiddleware
|
class APIAuthenticationMiddleware
|
||||||
|
@ -34,13 +35,16 @@ class APIAuthenticationMiddleware
|
||||||
|
|
||||||
if ($keyRecord && Hash::check($loneKey, $keyRecord->secret) && $keyRecord->status == 'active')
|
if ($keyRecord && Hash::check($loneKey, $keyRecord->secret) && $keyRecord->status == 'active')
|
||||||
{
|
{
|
||||||
Log::alert('API Authentication Success', [
|
|
||||||
'discriminator' => $discriminator
|
|
||||||
]);
|
|
||||||
|
|
||||||
$keyRecord->last_used = Carbon::now();
|
$keyRecord->last_used = Carbon::now();
|
||||||
$keyRecord->save();
|
$keyRecord->save();
|
||||||
|
|
||||||
|
Log::info('Recording API call, see context', [
|
||||||
|
'uri' => $request->url(),
|
||||||
|
'name' => Route::currentRouteName(),
|
||||||
|
'discriminator' => $discriminator,
|
||||||
|
'ip' => $request->ip()
|
||||||
|
]);
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue