Added admin layout

This commit is contained in:
2026-06-21 16:44:01 +02:00
parent a012c16425
commit 79bb186234
4 changed files with 70 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace App\Middleware;
use App\Enumerations\UserRole;
use App\Providers\AuthCheckProvider;
use Closure;
class AdminRoleMiddleware
{
public function handle($request, Closure $next)
{
if (!auth()->check()) {
return redirect('/login')->with('message', 'Du musst eingeloggt sein.');
}
$authCheck = new AuthCheckProvider();
$role = $authCheck->getUserRole();
if (!in_array($role, [UserRole::USER_ROLE_ADMIN, UserRole::USER_ROLE_GROUP_LEADER], true)) {
return redirect('/')->with('message', 'Du bist dazu nicht berechtigt.');
}
return $next($request);
}
}