protected function adminPanelRouteRegister() { if (SessionManager::has('auth') && SessionManager::get('auth') && $this->container->systemOptions->isDevMode()) { $this->app->get('/admin/generate_module', 'App\\Controllers\\Admin\\ModuleGenerator:index')->setName('developers.module.generator'); $this->app->post('/admin/generate_module', 'App\\Controllers\\Admin\\ModuleGenerator:doAdd')->setName('developers.module.generator.add'); } }
protected function adminPanelRouteRegister() { if (Session::has('auth') && Session::get('auth')) { AdminRouteCollection::add(new AdminResource('sections')); $this->adminPanelMenuRegister(); } }
public function __invoke($request, $response, $next) { if (Session::has('auth') && Session::get('auth') && $request->getMethod() == 'PUT') { return $next($request, $response); } $guard = new \Slim\Csrf\Guard('csrf', $t, null, 10); return $guard($request, $response, $next); }
public function __invoke(Request $request, Response $response, $next) { $this->req = $request; $this->res = $response; $allParams = new RequestParams($this->req); if (Session::has('auth') && Session::get('auth') && $allParams->all($this->variableName)) { $this->setOption($allParams->all($this->variableName), $allParams); } return $next($request, $response); }
/** * Example middleware invokable class * * @param \Psr\Http\Message\ServerRequestInterface $request PSR7 request * @param \Psr\Http\Message\ResponseInterface $response PSR7 response * @param callable $next Next middleware * * @return \Psr\Http\Message\ResponseInterface */ public function __invoke($request, $response, $next) { global $container; if (!Session::has('auth') || !Session::get('auth')) { $container->flash->addMessage('errors', 'Please authorize'); return $response->withStatus(302)->withHeader('Location', '/auth/login'); } $response = $next($request, $response); return $response; }
public static function add(Interfaces\IRouteResource $resource) { if (!Session::has('auth') || !Session::get('auth')) { return; } $info = $resource->getInfo(); $collectionName = str_replace('/', "_", substr($info['path'], 1)); if (isset(self::$collection[$collectionName])) { throw new \InvalidArgumentException("Resourse: " . $collectionName . " is registered. Please register other resource"); } self::$collection[$collectionName] = $resource; }
public function registerRoute() { $this->adminPanelRouteRegister(); $this->app->group('/admin', function () { $this->get('/', function ($req, $res) { return $res->withStatus(301)->withHeader('Location', $this->router->pathFor('dashboard')); }); $this->get('/dashboard', 'App\\Controllers\\Admin\\DashboardController:index')->setName('dashboard'); $this->get('/phpinfo', 'App\\Controllers\\Admin\\DeveloperController:phpinfo')->setName('phpinfo'); if (!Session::has('auth') || !Session::get('auth')) { $this->get('/{page:.*}', function ($req, $res) { return $res->withStatus(301)->withHeader('Location', $this->router->pathFor('dashboard')); }); } })->add(new AuthMiddleware()); }
public function __invoke(Request $request, Response $response, $next) { $this->req = $request; $this->res = $response; $allParams = new RequestParams($this->req); if (Session::has('auth') && Session::get('auth') && ($allParams->all($this->variableName[0]) || $allParams->all($this->variableName[1]))) { $this->groupName = $this->groupName . basename($allParams->getRequest()->getUri()->getPath()); $varName = $this->variableName[0]; if ($allParams->all($varName)) { $this->setOption($varName, $allParams); } $varName = $this->variableName[1]; if ($allParams->all($varName)) { $this->setOption($varName, $allParams); } } return $next($request, $response); }