ChangePasswordHandler.php 976 B

1234567891011121314151617181920212223242526272829303132333435
  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. private IURLGenerator $urlGenerator;
  16. public function __construct(IURLGenerator $urlGenerator) {
  17. $this->urlGenerator = $urlGenerator;
  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. }