ChangePasswordHandler.php 912 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\Settings\WellKnown;
  8. use OCP\AppFramework\Http\RedirectResponse;
  9. use OCP\Http\WellKnown\GenericResponse;
  10. use OCP\Http\WellKnown\IHandler;
  11. use OCP\Http\WellKnown\IRequestContext;
  12. use OCP\Http\WellKnown\IResponse;
  13. use OCP\IURLGenerator;
  14. class ChangePasswordHandler implements IHandler {
  15. public function __construct(
  16. private IURLGenerator $urlGenerator,
  17. ) {
  18. }
  19. public function handle(string $service, IRequestContext $context, ?IResponse $previousResponse): ?IResponse {
  20. if ($service !== 'change-password') {
  21. return $previousResponse;
  22. }
  23. $response = new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('settings.PersonalSettings.index', ['section' => 'security']));
  24. return new GenericResponse($response);
  25. }
  26. }