]> git.immae.eu Git - github/shaarli/Shaarli.git/blame - application/front/controllers/LoginController.php
Bump elliptic from 6.4.1 to 6.5.3
[github/shaarli/Shaarli.git] / application / front / controllers / LoginController.php
CommitLineData
6c50a6cc
A
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 {
27ceea2a
A
25 if ($this->container->loginManager->isLoggedIn()
26 || $this->container->conf->get('security.open_shaarli', false)
27 ) {
6c50a6cc
A
28 return $response->withRedirect('./');
29 }
30
27ceea2a 31 $userCanLogin = $this->container->loginManager->canLogin($request->getServerParams());
6c50a6cc
A
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')))
27ceea2a
A
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'))
6c50a6cc
A
44 ;
45
0498b209 46 return $response->write($this->render('loginform'));
6c50a6cc
A
47 }
48}