mirror of
https://github.com/anna-sara/vbytes_lan.git
synced 2025-12-24 05:17:13 +01:00
Added api-key to header
This commit is contained in:
parent
2eaf312f25
commit
00dac42e2c
5 changed files with 22 additions and 22 deletions
|
|
@ -159,7 +159,7 @@ class ParticipantsTable
|
||||||
->action(function (array $data, Participant $record) {
|
->action(function (array $data, Participant $record) {
|
||||||
$mailContent = Mailtemplate::where('id', $data['mailtemplate'])->get();
|
$mailContent = Mailtemplate::where('id', $data['mailtemplate'])->get();
|
||||||
Mail::to($record->guardian_email)
|
Mail::to($record->guardian_email)
|
||||||
->send(new LanMail($mailContent, $record));
|
->queue(new LanMail($mailContent, $record));
|
||||||
Participant::where('id', $record->id)->update(['emailed' => true]);
|
Participant::where('id', $record->id)->update(['emailed' => true]);
|
||||||
})
|
})
|
||||||
->hidden(fn($record) => !$record->emailed)
|
->hidden(fn($record) => !$record->emailed)
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ class VolunteersTable
|
||||||
->action(function (array $data, Volunteer $record) {
|
->action(function (array $data, Volunteer $record) {
|
||||||
$mailContent = Mailtemplate::where('id', $data['mailtemplate'])->get();
|
$mailContent = Mailtemplate::where('id', $data['mailtemplate'])->get();
|
||||||
Mail::to($record->email)
|
Mail::to($record->email)
|
||||||
->send(new LanMail($mailContent, $record));
|
->queue(new LanMail($mailContent, $record));
|
||||||
Volunteer::where('id', $record->id)->update(['emailed' => true]);
|
Volunteer::where('id', $record->id)->update(['emailed' => true]);
|
||||||
})
|
})
|
||||||
->hidden(fn($record) => $record->emailed),
|
->hidden(fn($record) => $record->emailed),
|
||||||
|
|
|
||||||
|
|
@ -15,19 +15,19 @@ class ApiToken
|
||||||
*/
|
*/
|
||||||
public function handle(Request $request, Closure $next): Response
|
public function handle(Request $request, Closure $next): Response
|
||||||
{
|
{
|
||||||
if ($request->api_token === config('apikeys.key_1')) {
|
if ($request->header('X-API-KEY') === config('apikeys.key_1')) {
|
||||||
|
|
||||||
$request->merge(["permission" => "key_1"]);
|
$request->merge(["permission" => "key_1"]);
|
||||||
|
|
||||||
} elseif ($request->api_token === config('apikeys.key_2')) {
|
} elseif ($request->header('X-API-KEY') === config('apikeys.key_2')) {
|
||||||
|
|
||||||
$request->merge(["permission" => "key_2"]);
|
$request->merge(["permission" => "key_2"]);
|
||||||
|
|
||||||
} elseif ($request->api_token === config('apikeys.key_3')) {
|
} elseif ($request->header('X-API-KEY') === config('apikeys.key_3')) {
|
||||||
|
|
||||||
$request->merge(["permission" => "key_3"]);
|
$request->merge(["permission" => "key_3"]);
|
||||||
|
|
||||||
} elseif ($request->api_token === config('apikeys.key_4')) {
|
} elseif ($request->header('X-API-KEY') === config('apikeys.key_4')) {
|
||||||
|
|
||||||
$request->merge(["permission" => "key_4"]);
|
$request->merge(["permission" => "key_4"]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
## Endpoints
|
## Endpoints
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary><code>GET</code> <code><b>/data/{api_token}</b></code></summary>
|
<summary><code>GET</code> <code><b>/data</b></code></summary>
|
||||||
|
|
||||||
##### Parameters
|
##### Headers
|
||||||
|
|
||||||
> | name | type | data type | description |
|
> | name | type | data type | description |
|
||||||
> |-------------|------------|----------------|--------------------------------------------------------------|
|
> |-------------|------------|----------------|--------------------------------------------------------------|
|
||||||
> | `api_token` | required | string | Api key with permission |
|
> | `x-api-key` | required | string | Api key with permission |
|
||||||
|
|
||||||
|
|
||||||
##### Responses
|
##### Responses
|
||||||
|
|
@ -124,13 +124,13 @@
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary><code>GET</code> <code><b>/version/{api_token}</b></code></summary>
|
<summary><code>GET</code> <code><b>/version</b></code></summary>
|
||||||
|
|
||||||
##### Parameters
|
##### Headers
|
||||||
|
|
||||||
> | name | type | data type | description |
|
> | name | type | data type | description |
|
||||||
> |-------------|------------|----------------|--------------------------------------------------------------|
|
> |-------------|------------|----------------|--------------------------------------------------------------|
|
||||||
> | `api_token` | required | string | Api key with permission |
|
> | `x-api-key` | required | string | Api key with permission |
|
||||||
|
|
||||||
##### Responses
|
##### Responses
|
||||||
|
|
||||||
|
|
@ -181,13 +181,13 @@
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary><code>POST</code> <code><b>/participant/{api_token}</b></code></summary>
|
<summary><code>POST</code> <code><b>/participant</b></code></summary>
|
||||||
|
|
||||||
##### Parameters
|
##### Headers
|
||||||
|
|
||||||
> | name | type | data type | description |
|
> | name | type | data type | description |
|
||||||
> |-------------|-----------|-------------------------|-----------------------------------------------------------------------|
|
> |-------------|-----------|-------------------------|-----------------------------------------------------------------------|
|
||||||
> | `api_token` | required | string | Api key with permission |
|
> | `x-api-key` | required | string | Api key with permission |
|
||||||
|
|
||||||
##### Body data
|
##### Body data
|
||||||
|
|
||||||
|
|
@ -237,13 +237,13 @@
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary><code>POST</code> <code><b>/volunteer/{api_token}</b></code></summary>
|
<summary><code>POST</code> <code><b>/volunteer</b></code></summary>
|
||||||
|
|
||||||
##### Parameters
|
##### Headers
|
||||||
|
|
||||||
> | name | type | data type | description |
|
> | name | type | data type | description |
|
||||||
> |-------------|-----------|-------------------------|-----------------------------------------------------------------------|
|
> |-------------|-----------|-------------------------|-----------------------------------------------------------------------|
|
||||||
> | `api_token` | required | string | Api key with permission |
|
> | `x-api-key` | required | string | Api key with permission |
|
||||||
|
|
||||||
|
|
||||||
##### Body data
|
##### Body data
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,10 @@ use App\Http\Controllers\VersionController;
|
||||||
// return $request->user();
|
// return $request->user();
|
||||||
//})->middleware('auth:sanctum');
|
//})->middleware('auth:sanctum');
|
||||||
|
|
||||||
Route::get('/data/{api_token}', [ParticipantController::class, 'index'] )->middleware([ApiToken::class]);
|
Route::get('/data', [ParticipantController::class, 'index'] )->middleware([ApiToken::class]);
|
||||||
|
|
||||||
Route::get('/version/{api_token}', [VersionController::class, 'index'] )->middleware([ApiToken::class]);
|
Route::get('/version', [VersionController::class, 'index'] )->middleware([ApiToken::class]);
|
||||||
|
|
||||||
Route::post('/participant/{api_token}', [ParticipantController::class, 'store'] )->middleware([ApiToken::class]);
|
Route::post('/participant', [ParticipantController::class, 'store'] )->middleware([ApiToken::class]);
|
||||||
|
|
||||||
Route::post('/volunteer/{api_token}', [VolunteerController::class, 'store'] )->middleware([ApiToken::class]);
|
Route::post('/volunteer', [VolunteerController::class, 'store'] )->middleware([ApiToken::class]);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue