public function login() { if (isset($_SESSION['authenticated']) && $_SESSION['authenticated']) { $this->app->response->redirect($this->app->urlFor('admin')); } if ($this->app->request->isGet()) { $this->app->render($this->themeService->getTemplate('login.html.twig'), array('name' => $this->settingRepository->getName())); } else { if ($this->app->request->isPost()) { $password = $this->app->request->post('password'); if (crypt($password, $this->settingRepository->getPassword()) === $this->settingRepository->getPassword()) { $_SESSION['authenticated'] = true; $this->app->response->redirect($this->app->urlFor('admin')); } else { $this->app->flashNow('login_error', 'Incorrect Password.'); $this->app->render($this->themeService->getTemplate('login.html.twig'), array('name' => $this->settingRepository->getName()), 403); } } } }