glastree_on_gitea
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
abstract class Controller
|
||||
{
|
||||
use AuthorizesRequests;
|
||||
|
||||
protected function authorizeWrite(string $module): void
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user->isSuperAdmin()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$user->canManage($module)) {
|
||||
abort(403, 'Non hai i permessi per modificare ' . $module);
|
||||
}
|
||||
}
|
||||
|
||||
protected function authorizeRead(string $module): void
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user->isSuperAdmin()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$user->canAccess($module)) {
|
||||
abort(403, 'Non hai i permessi per visualizzare ' . $module);
|
||||
}
|
||||
}
|
||||
|
||||
protected function authorizeDelete(string $module): void
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user->isSuperAdmin()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$user->canDelete($module)) {
|
||||
abort(403, 'Non hai i permessi per eliminare ' . $module);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user