Skip to content

Commit

Permalink
Modify 'VerifyCsrfToken' to not be active when App::environment is se…
Browse files Browse the repository at this point in the history
…t to 'ci'
  • Loading branch information
xam-ps committed Dec 29, 2024
1 parent 309385a commit 8105ef5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 10 additions & 0 deletions app/Http/Middleware/VerifyCsrfToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
use Illuminate\Support\Facades\App;

class VerifyCsrfToken extends Middleware
{
Expand All @@ -14,4 +15,13 @@ class VerifyCsrfToken extends Middleware
protected $except = [
//
];

public function handle($request, \Closure $next)
{
if (App::environment(['ci'])) {
$this->except = ['*'];
}

return parent::handle($request, $next);
}
}
2 changes: 0 additions & 2 deletions tests/Feature/RevenueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ public function test_store_revenue_is_working(): void
$revenue->payment_date = '2021-01-01';
$revenue->invoice_number = '12345678';
$formData = $revenue->toArray();
$formData['_token'] = 'bzz';

$response = $this->actingAs($user)
->withSession(['_token' => 'bzz'])
->post('/revenue', $formData);

$this->assertDatabaseHas('revenues', [
Expand Down

0 comments on commit 8105ef5

Please sign in to comment.