Password.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\Settings\Settings\Personal\Security;
  8. use OCP\AppFramework\Http\TemplateResponse;
  9. use OCP\IUserManager;
  10. use OCP\Settings\ISettings;
  11. class Password implements ISettings {
  12. /** @var IUserManager */
  13. private $userManager;
  14. /** @var string|null */
  15. private $uid;
  16. public function __construct(IUserManager $userManager,
  17. ?string $UserId) {
  18. $this->userManager = $userManager;
  19. $this->uid = $UserId;
  20. }
  21. public function getForm(): TemplateResponse {
  22. $user = $this->userManager->get($this->uid);
  23. $passwordChangeSupported = false;
  24. if ($user !== null) {
  25. $passwordChangeSupported = $user->canChangePassword();
  26. }
  27. return new TemplateResponse('settings', 'settings/personal/security/password', [
  28. 'passwordChangeSupported' => $passwordChangeSupported,
  29. ]);
  30. }
  31. public function getSection(): string {
  32. return 'security';
  33. }
  34. public function getPriority(): int {
  35. return 10;
  36. }
  37. }