Snapshot of main at 9f39a6e1e (2026-11-02)
This commit is contained in:
commit
6ccf1792d7
2580 files changed
+1040202
No files matched your search
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class CanOnWebGuard
|
||||
{
|
||||
public function handle($request, Closure $next, ...$permissions)
|
||||
{
|
||||
$user = Auth::guard('web')->user();
|
||||
|
||||
if (!$user) {
|
||||
abort(403, 'Unauthorized action.');
|
||||
}
|
||||
|
||||
// Use can() instead of hasPermissionTo() to work with Gate definitions
|
||||
// can() is more flexible and works with the multi-guard permission system.
|
||||
// Multiple middleware params are treated as "any of" (e.g. `user.can:access profiles,access accounts`).
|
||||
foreach ($permissions as $permission) {
|
||||
if ($user->can($permission)) {
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
||||
abort(403, 'Unauthorized action.');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user