feat(auth): introduce resource creation authorization middleware and policies for enhanced access control
This commit is contained in:
20
app/Traits/AuthorizesResourceCreation.php
Normal file
20
app/Traits/AuthorizesResourceCreation.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
|
||||
trait AuthorizesResourceCreation
|
||||
{
|
||||
use AuthorizesRequests;
|
||||
|
||||
/**
|
||||
* Authorize creation of all supported resources.
|
||||
*
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
protected function authorizeResourceCreation(): void
|
||||
{
|
||||
$this->authorize('createAnyResource');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user