LoginController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 43
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A loginAction() 0 10 2
A postLoginAction() 0 15 2
1
<?php
2
3
namespace Egzaminer\Controller;
4
5
class LoginController extends AbstractController
6
{
7
    /**
8
     * Login page.
9
     *
10
     * GET /admin/login
11
     *
12
     * @return string
13
     */
14
    public function loginAction(): string
15
    {
16
        if ($this->isLogged()) {
17
            $this->redirect('/admin');
18
19
            $this->terminate();
20
        }
21
22
        return $this->render('front/login', ['title' => 'Logowanie']);
23
    }
24
25
    /**
26
     * Login post action.
27
     *
28
     * POST /admin/login
29
     *
30
     * @return void
31
     */
32
    public function postLoginAction()
33
    {
34
        if (true === $this->get('auth')->login(
35
                $this->getFromRequest('post', 'username'),
36
                $this->getFromRequest('post', 'password')
37
            )) {
38
            $this->setMessage('success', 'Zalogowano pomyślnie!');
39
            $this->redirect('/admin');
40
41
            $this->terminate();
42
        }
43
44
        $this->setMessage('warning', 'Złe hasło!');
45
        $this->redirect('/admin/login');
46
    }
47
}
48