Security:3 Fix HMAC handshake, generate API keys in Google Login, and relax JWT issuer
This commit is contained in:
30
app/Traits/ApiResponses.php
Normal file
30
app/Traits/ApiResponses.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
trait ApiResponses
|
||||
{
|
||||
/**
|
||||
* Return a success JSON response.
|
||||
*/
|
||||
protected function success(array $data, int $code = 200): JsonResponse
|
||||
{
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'data' => $data,
|
||||
], $code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a failure JSON response.
|
||||
*/
|
||||
protected function failure(string $message, int $code = 401): JsonResponse
|
||||
{
|
||||
return response()->json([
|
||||
'status' => 'failure',
|
||||
'message' => $message,
|
||||
], $code);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user