2017-05-17 07:41:20 -04:00
|
|
|
<?php
|
2020-03-31 04:49:10 -04:00
|
|
|
|
2020-01-30 07:24:10 -05:00
|
|
|
declare(strict_types=1);
|
2020-03-31 04:49:10 -04:00
|
|
|
|
2017-05-17 07:41:20 -04:00
|
|
|
/**
|
|
|
|
|
* @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
|
|
|
|
|
*
|
|
|
|
|
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
|
2019-12-03 13:57:53 -05:00
|
|
|
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
|
|
|
|
* @author Julius Härtl <jus@bitgrid.net>
|
|
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2017-05-17 07:41:20 -04:00
|
|
|
*
|
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
2019-12-03 13:57:53 -05:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2017-05-17 07:41:20 -04:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2020-01-30 07:30:45 -05:00
|
|
|
namespace OCA\Settings\Settings\Personal\Security;
|
2017-05-17 07:41:20 -04:00
|
|
|
|
|
|
|
|
use OCP\AppFramework\Http\TemplateResponse;
|
2018-06-29 07:01:22 -04:00
|
|
|
use OCP\IUserManager;
|
2017-05-17 07:41:20 -04:00
|
|
|
use OCP\Settings\ISettings;
|
|
|
|
|
|
2020-01-30 07:24:10 -05:00
|
|
|
class Password implements ISettings {
|
2017-05-17 07:41:20 -04:00
|
|
|
|
2018-09-26 10:25:18 -04:00
|
|
|
/** @var IUserManager */
|
2018-06-29 07:01:22 -04:00
|
|
|
private $userManager;
|
|
|
|
|
|
2019-09-09 16:12:29 -04:00
|
|
|
/** @var string|null */
|
2019-03-01 08:09:54 -05:00
|
|
|
private $uid;
|
2019-09-09 16:12:29 -04:00
|
|
|
|
2020-01-28 14:48:18 -05:00
|
|
|
public function __construct(IUserManager $userManager,
|
2019-03-01 08:09:54 -05:00
|
|
|
?string $UserId) {
|
2018-06-29 07:01:22 -04:00
|
|
|
$this->userManager = $userManager;
|
2019-03-01 08:09:54 -05:00
|
|
|
$this->uid = $UserId;
|
2018-06-29 07:01:22 -04:00
|
|
|
}
|
|
|
|
|
|
2019-09-09 16:12:29 -04:00
|
|
|
public function getForm(): TemplateResponse {
|
2019-03-01 08:09:54 -05:00
|
|
|
$user = $this->userManager->get($this->uid);
|
2018-06-29 07:01:22 -04:00
|
|
|
$passwordChangeSupported = false;
|
|
|
|
|
if ($user !== null) {
|
|
|
|
|
$passwordChangeSupported = $user->canChangePassword();
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-30 07:24:10 -05:00
|
|
|
return new TemplateResponse('settings', 'settings/personal/security/password', [
|
2018-09-26 10:25:18 -04:00
|
|
|
'passwordChangeSupported' => $passwordChangeSupported,
|
2018-06-29 07:01:22 -04:00
|
|
|
]);
|
2017-05-17 07:41:20 -04:00
|
|
|
}
|
|
|
|
|
|
2019-09-09 16:12:29 -04:00
|
|
|
public function getSection(): string {
|
2017-06-16 09:34:16 -04:00
|
|
|
return 'security';
|
2017-05-17 07:41:20 -04:00
|
|
|
}
|
|
|
|
|
|
2019-09-09 16:12:29 -04:00
|
|
|
public function getPriority(): int {
|
2017-05-17 07:41:20 -04:00
|
|
|
return 10;
|
|
|
|
|
}
|
|
|
|
|
}
|