Skip to content

Commit

Permalink
Merge pull request #5 from The-3Labs-Team/protect-API-with-middleware
Browse files Browse the repository at this point in the history
Protect API routes with nova:api middleware
  • Loading branch information
murdercode authored Jan 29, 2024
2 parents a27f4a1 + b0b277a commit 8226e44
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dist/js/field.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions resources/js/components/FormField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default {
async checkIfIsNotBusy() {
try {
const response = await fetch('/api/busy-is-busy', {
const response = await fetch('/nova-vendor/the-3labs-team/nova-busy-resource-field/is-busy', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -77,7 +77,7 @@ export default {
async storeAccess() {
const response = await fetch('/api/busy-store-busy', {
const response = await fetch('/nova-vendor/the-3labs-team/nova-busy-resource-field/store-busy', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/IndexField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default {
methods: {
async fetchData() {
try {
const response = await fetch('/api/busy-is-busy', {
const response = await fetch('/nova-vendor/the-3labs-team/nova-busy-resource-field/is-busy', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
6 changes: 3 additions & 3 deletions routes/api.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use Illuminate\Support\Facades\Route;
use The3labsTeam\NovaBusyResourceField\App\Http\Controllers\BusyController;

/*
|--------------------------------------------------------------------------
Expand All @@ -13,6 +14,5 @@
|
*/

Route::post('/api/busy-is-busy', [\The3labsTeam\NovaBusyResourceField\App\Http\Controllers\BusyController::class, 'isBusy']);
Route::post('/api/busy-store-busy', [\The3labsTeam\NovaBusyResourceField\App\Http\Controllers\BusyController::class, 'storeBusy']);
Route::post('/api/busy-update-busy-date', [\The3labsTeam\NovaBusyResourceField\App\Http\Controllers\BusyController::class, 'updateBusyDate']);
Route::post('/is-busy', [BusyController::class, 'isBusy']);
Route::post('/store-busy', [BusyController::class, 'storeBusy']);
3 changes: 2 additions & 1 deletion src/FieldServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ protected function routes()
return;
}

Route::middleware(['nova'])
Route::middleware(['nova:api'])
->prefix('nova-vendor/the-3labs-team/nova-busy-resource-field')
->group(__DIR__.'/../routes/api.php');
}

Expand Down

0 comments on commit 8226e44

Please sign in to comment.