|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* Copyright (C) 2024 Rafael San José <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* This program is free software; you can redistribute it and/or modify |
|
6
|
|
|
* it under the terms of the GNU General Public License as published by |
|
7
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
|
8
|
|
|
* any later version. |
|
9
|
|
|
* |
|
10
|
|
|
* This program is distributed in the hope that it will be useful, |
|
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13
|
|
|
* GNU General Public License for more details. |
|
14
|
|
|
* |
|
15
|
|
|
* You should have received a copy of the GNU General Public License |
|
16
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
17
|
|
|
*/ |
|
18
|
|
|
|
|
19
|
|
|
namespace CoreModules\Admin\Controller; |
|
20
|
|
|
|
|
21
|
|
|
use Alxarafe\Base\Controller\ViewController; |
|
22
|
|
|
|
|
23
|
|
|
class ConfigController extends ViewController |
|
24
|
|
|
{ |
|
25
|
|
|
|
|
26
|
|
|
public function doIndex(): bool |
|
27
|
|
|
{ |
|
28
|
|
|
/** |
|
29
|
|
|
* TODO: The value of this variable will be filled in when the roles |
|
30
|
|
|
* are correctly implemented. |
|
31
|
|
|
*/ |
|
32
|
|
|
$restricted_access = false; |
|
33
|
|
|
|
|
34
|
|
|
$this->template = 'page/config'; |
|
35
|
|
|
if (isset($this->config) && $restricted_access) { |
|
|
|
|
|
|
36
|
|
|
$this->template = 'page/forbidden'; |
|
37
|
|
|
} |
|
38
|
|
|
return true; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function doLogin() |
|
42
|
|
|
{ |
|
43
|
|
|
$this->template = 'page/admin/login'; |
|
44
|
|
|
$login = filter_input(INPUT_POST, 'login'); |
|
45
|
|
|
if (!$login) { |
|
46
|
|
|
return true; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
$username = filter_input(INPUT_POST, 'username'); |
|
50
|
|
|
$password = filter_input(INPUT_POST, 'password'); |
|
51
|
|
|
if (!Auth::login($username, $password)) { |
|
52
|
|
|
$this->advice[] = $this->langs->trans('ErrorBadLoginPassword'); |
|
|
|
|
|
|
53
|
|
|
dump([ |
|
|
|
|
|
|
54
|
|
|
'ConfigController' => $this |
|
55
|
|
|
]); |
|
56
|
|
|
return true; |
|
57
|
|
|
} |
|
58
|
|
|
$this->template = 'page/admin/info'; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function doLogout() |
|
62
|
|
|
{ |
|
63
|
|
|
Auth::logout(true); |
|
64
|
|
|
return true; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function doSave(): bool |
|
68
|
|
|
{ |
|
69
|
|
|
dump([ |
|
|
|
|
|
|
70
|
|
|
'ConfigController save' => $_POST, |
|
71
|
|
|
]); |
|
72
|
|
|
return false; |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|