From 6c50a6ccceecf54850e62c312ab2397b84d89ab4 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 18 Jan 2020 17:50:11 +0100 Subject: Render login page through Slim controller --- application/front/controllers/LoginController.php | 46 +++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 application/front/controllers/LoginController.php (limited to 'application/front/controllers/LoginController.php') diff --git a/application/front/controllers/LoginController.php b/application/front/controllers/LoginController.php new file mode 100644 index 00000000..47fa3ee3 --- /dev/null +++ b/application/front/controllers/LoginController.php @@ -0,0 +1,46 @@ +ci->loginManager->isLoggedIn() || $this->ci->conf->get('security.open_shaarli', false)) { + return $response->withRedirect('./'); + } + + $userCanLogin = $this->ci->loginManager->canLogin($request->getServerParams()); + if ($userCanLogin !== true) { + throw new LoginBannedException(); + } + + if ($request->getParam('username') !== null) { + $this->assignView('username', escape($request->getParam('username'))); + } + + $this + ->assignView('returnurl', escape($request->getServerParam('HTTP_REFERER'))) + ->assignView('remember_user_default', $this->ci->conf->get('privacy.remember_user_default', true)) + ->assignView('pagetitle', t('Login') .' - '. $this->ci->conf->get('general.title', 'Shaarli')) + ; + + return $response->write($this->ci->pageBuilder->render('loginform')); + } +} -- cgit v1.2.3 From 0498b209b551cad5595312583e5d6fb1bc3303a5 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Thu, 23 Jan 2020 20:06:32 +0100 Subject: Execute common plugin hooks before rendering login page --- application/front/controllers/LoginController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'application/front/controllers/LoginController.php') diff --git a/application/front/controllers/LoginController.php b/application/front/controllers/LoginController.php index 47fa3ee3..23efb592 100644 --- a/application/front/controllers/LoginController.php +++ b/application/front/controllers/LoginController.php @@ -41,6 +41,6 @@ class LoginController extends ShaarliController ->assignView('pagetitle', t('Login') .' - '. $this->ci->conf->get('general.title', 'Shaarli')) ; - return $response->write($this->ci->pageBuilder->render('loginform')); + return $response->write($this->render('loginform')); } } -- cgit v1.2.3 From 27ceea2aeeed69b43fef4ebff35ec8004fcc2e45 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sun, 26 Jan 2020 09:06:13 +0100 Subject: Rename ci attribute to container --- application/front/controllers/LoginController.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'application/front/controllers/LoginController.php') diff --git a/application/front/controllers/LoginController.php b/application/front/controllers/LoginController.php index 23efb592..ae3599e0 100644 --- a/application/front/controllers/LoginController.php +++ b/application/front/controllers/LoginController.php @@ -22,11 +22,13 @@ class LoginController extends ShaarliController { public function index(Request $request, Response $response): Response { - if ($this->ci->loginManager->isLoggedIn() || $this->ci->conf->get('security.open_shaarli', false)) { + if ($this->container->loginManager->isLoggedIn() + || $this->container->conf->get('security.open_shaarli', false) + ) { return $response->withRedirect('./'); } - $userCanLogin = $this->ci->loginManager->canLogin($request->getServerParams()); + $userCanLogin = $this->container->loginManager->canLogin($request->getServerParams()); if ($userCanLogin !== true) { throw new LoginBannedException(); } @@ -37,8 +39,8 @@ class LoginController extends ShaarliController $this ->assignView('returnurl', escape($request->getServerParam('HTTP_REFERER'))) - ->assignView('remember_user_default', $this->ci->conf->get('privacy.remember_user_default', true)) - ->assignView('pagetitle', t('Login') .' - '. $this->ci->conf->get('general.title', 'Shaarli')) + ->assignView('remember_user_default', $this->container->conf->get('privacy.remember_user_default', true)) + ->assignView('pagetitle', t('Login') .' - '. $this->container->conf->get('general.title', 'Shaarli')) ; return $response->write($this->render('loginform')); -- cgit v1.2.3