Skip to content

Commit

Permalink
route forbidden issue fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AravindRam-Ranium committed Feb 21, 2024
1 parent 3aacd97 commit bdf4725
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
17 changes: 16 additions & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
<?php

use Filament\Http\Middleware\Authenticate;
use Illuminate\Cookie\Middleware\EncryptCookies;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
use Illuminate\Session\Middleware\AuthenticateSession;
use Illuminate\Session\Middleware\StartSession;
use Illuminate\Support\Facades\Route;
use Visualbuilder\FilamentUserConsent\Livewire\ConsentOptionRequest;

//Routes for users to view and save their consent
Route::get('consent-option-request', ConsentOptionRequest::class)->name('consent-option-request');

Route::middleware([
EncryptCookies::class,
StartSession::class,
VerifyCsrfToken::class,
AuthenticateSession::class,
Authenticate::class,
'auth:admin,practitioner,enduser'
])->group(function () {
Route::get('consent-option-request', ConsentOptionRequest::class)->name('consent-option-request');
});
15 changes: 2 additions & 13 deletions src/FilamentUserConsentServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
use Spatie\LaravelPackageTools\PackageServiceProvider;
use Visualbuilder\FilamentUserConsent\Commands\FilamentUserConsentCommand;
use Visualbuilder\FilamentUserConsent\Testing\TestsFilamentUserConsent;
use Illuminate\Cookie\Middleware\EncryptCookies;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
use Illuminate\Session\Middleware\AuthenticateSession;
use Illuminate\Session\Middleware\StartSession;

class FilamentUserConsentServiceProvider extends PackageServiceProvider
{
public static string $name = 'filament-user-consent';
Expand Down Expand Up @@ -62,15 +59,7 @@ public function configurePackage(Package $package): void
$package->hasViews(static::$viewNamespace);
}

Route::middleware([
EncryptCookies::class,
StartSession::class,
VerifyCsrfToken::class,
AuthenticateSession::class,
'admin,practitioner,enduser'
])->group(function () {
$this->registerRoutes();
});
$this->registerRoutes();
}

public function packageRegistered(): void
Expand Down
4 changes: 4 additions & 0 deletions src/Livewire/ConsentOptionRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class ConsentOptionRequest extends SimplePage

public $acceptConsents = [];

public $errorBags = [];

public function mount(): void
{
$this->user = auth()->user();
Expand Down Expand Up @@ -164,6 +166,8 @@ public function validateConsents($action)
}
}

$this->errorBags = $errorBags;

$validateMandatoryConsents = $this->user->requiredOutstandingConsentsValidate($conentIds);

if (! $validateMandatoryConsents || count($errorBags) > 0) {
Expand Down

0 comments on commit bdf4725

Please sign in to comment.