Password.php 1.9 KB

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