add(new \Slim\Extras\Middleware\FeatherBBAuth()); * */ namespace FeatherBB\Middleware; use FeatherBB\Core\Interfaces\ForumEnv; use FeatherBB\Core\Interfaces\Router; use FeatherBB\Core\Interfaces\User; /** * Middleware to check if user is logged and admin */ class Admin { public function __invoke($request, $response, $next) { // Redirect user to home page if not admin if (User::get()->g_id != ForumEnv::get('FEATHER_ADMIN')) { return Router::redirect(Router::pathFor('home'), __('No permission')); } $response = $next($request, $response); return $response; } }