1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
/** |
4
|
|
|
* @copyright Copyright (c) 2017 Arthur Schiwon <[email protected]> |
5
|
|
|
* |
6
|
|
|
* @author Arthur Schiwon <[email protected]> |
7
|
|
|
* @author Christoph Wurst <[email protected]> |
8
|
|
|
* @author Greta Doci <[email protected]> |
9
|
|
|
* @author Julius Härtl <[email protected]> |
10
|
|
|
* @author Roeland Jago Douma <[email protected]> |
11
|
|
|
* |
12
|
|
|
* @license GNU AGPL version 3 or any later version |
13
|
|
|
* |
14
|
|
|
* This program is free software: you can redistribute it and/or modify |
15
|
|
|
* it under the terms of the GNU Affero General Public License as |
16
|
|
|
* published by the Free Software Foundation, either version 3 of the |
17
|
|
|
* License, or (at your option) any later version. |
18
|
|
|
* |
19
|
|
|
* This program is distributed in the hope that it will be useful, |
20
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
21
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22
|
|
|
* GNU Affero General Public License for more details. |
23
|
|
|
* |
24
|
|
|
* You should have received a copy of the GNU Affero General Public License |
25
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
26
|
|
|
* |
27
|
|
|
*/ |
28
|
|
|
|
29
|
|
|
namespace OCA\Settings\Settings\Personal\Security; |
30
|
|
|
|
31
|
|
|
use OCP\AppFramework\Http\TemplateResponse; |
32
|
|
|
use OCP\IUserManager; |
33
|
|
|
use OCP\Settings\ISettings; |
34
|
|
|
|
35
|
|
|
class Password implements ISettings { |
36
|
|
|
|
37
|
|
|
/** @var IUserManager */ |
38
|
|
|
private $userManager; |
39
|
|
|
|
40
|
|
|
/** @var string|null */ |
41
|
|
|
private $uid; |
42
|
|
|
|
43
|
|
|
public function __construct(IUserManager $userManager, |
44
|
|
|
?string $UserId) { |
45
|
|
|
$this->userManager = $userManager; |
46
|
|
|
$this->uid = $UserId; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function getForm(): TemplateResponse { |
50
|
|
|
$user = $this->userManager->get($this->uid); |
51
|
|
|
$passwordChangeSupported = false; |
52
|
|
|
if ($user !== null) { |
53
|
|
|
$passwordChangeSupported = $user->canChangePassword(); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
return new TemplateResponse('settings', 'settings/personal/security/password', [ |
57
|
|
|
'passwordChangeSupported' => $passwordChangeSupported, |
58
|
|
|
]); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function getSection(): string { |
62
|
|
|
return 'security'; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function getPriority(): int { |
66
|
|
|
return 10; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|