aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/front/controllers/LoginController.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-01-26 11:41:10 +0100
committerGitHub <noreply@github.com>2020-01-26 11:41:10 +0100
commitc653ae3bfb11f663a52f55817e6d02a66d0852c8 (patch)
treed5a03a3e425180f1fafb646c8ec68a4b8458d0b3 /application/front/controllers/LoginController.php
parent1410dce2db310e71b5e683b0871c2f28d8807844 (diff)
parent27ceea2aeeed69b43fef4ebff35ec8004fcc2e45 (diff)
downloadShaarli-c653ae3bfb11f663a52f55817e6d02a66d0852c8.tar.gz
Shaarli-c653ae3bfb11f663a52f55817e6d02a66d0852c8.tar.zst
Shaarli-c653ae3bfb11f663a52f55817e6d02a66d0852c8.zip
Render login page through Slim controller (#1401)
Render login page through Slim controller
Diffstat (limited to 'application/front/controllers/LoginController.php')
-rw-r--r--application/front/controllers/LoginController.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/application/front/controllers/LoginController.php b/application/front/controllers/LoginController.php
new file mode 100644
index 00000000..ae3599e0
--- /dev/null
+++ b/application/front/controllers/LoginController.php
@@ -0,0 +1,48 @@
1<?php
2
3declare(strict_types=1);
4
5namespace Shaarli\Front\Controller;
6
7use Shaarli\Front\Exception\LoginBannedException;
8use Slim\Http\Request;
9use Slim\Http\Response;
10
11/**
12 * Class LoginController
13 *
14 * Slim controller used to render the login page.
15 *
16 * The login page is not available if the user is banned
17 * or if open shaarli setting is enabled.
18 *
19 * @package Front\Controller
20 */
21class LoginController extends ShaarliController
22{
23 public function index(Request $request, Response $response): Response
24 {
25 if ($this->container->loginManager->isLoggedIn()
26 || $this->container->conf->get('security.open_shaarli', false)
27 ) {
28 return $response->withRedirect('./');
29 }
30
31 $userCanLogin = $this->container->loginManager->canLogin($request->getServerParams());
32 if ($userCanLogin !== true) {
33 throw new LoginBannedException();
34 }
35
36 if ($request->getParam('username') !== null) {
37 $this->assignView('username', escape($request->getParam('username')));
38 }
39
40 $this
41 ->assignView('returnurl', escape($request->getServerParam('HTTP_REFERER')))
42 ->assignView('remember_user_default', $this->container->conf->get('privacy.remember_user_default', true))
43 ->assignView('pagetitle', t('Login') .' - '. $this->container->conf->get('general.title', 'Shaarli'))
44 ;
45
46 return $response->write($this->render('loginform'));
47 }
48}