Password.php 942 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. public function __construct(
  13. private IUserManager $userManager,
  14. private ?string $userId,
  15. ) {
  16. }
  17. public function getForm(): TemplateResponse {
  18. $user = $this->userManager->get($this->userId);
  19. $passwordChangeSupported = false;
  20. if ($user !== null) {
  21. $passwordChangeSupported = $user->canChangePassword();
  22. }
  23. return new TemplateResponse('settings', 'settings/personal/security/password', [
  24. 'passwordChangeSupported' => $passwordChangeSupported,
  25. ]);
  26. }
  27. public function getSection(): string {
  28. return 'security';
  29. }
  30. public function getPriority(): int {
  31. return 10;
  32. }
  33. }