ErrorController.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 OC\Core\Controller;
  8. use OCP\AppFramework\Http;
  9. use OCP\AppFramework\Http\Attribute\FrontpageRoute;
  10. use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
  11. use OCP\AppFramework\Http\Attribute\OpenAPI;
  12. use OCP\AppFramework\Http\Attribute\PublicPage;
  13. use OCP\AppFramework\Http\TemplateResponse;
  14. #[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)]
  15. class ErrorController extends \OCP\AppFramework\Controller {
  16. #[PublicPage]
  17. #[NoCSRFRequired]
  18. #[FrontpageRoute(verb: 'GET', url: 'error/403')]
  19. public function error403(): TemplateResponse {
  20. $response = new TemplateResponse(
  21. 'core',
  22. '403',
  23. [],
  24. 'error'
  25. );
  26. $response->setStatus(Http::STATUS_FORBIDDEN);
  27. return $response;
  28. }
  29. #[PublicPage]
  30. #[NoCSRFRequired]
  31. #[FrontpageRoute(verb: 'GET', url: 'error/404')]
  32. public function error404(): TemplateResponse {
  33. $response = new TemplateResponse(
  34. 'core',
  35. '404',
  36. [],
  37. 'error'
  38. );
  39. $response->setStatus(Http::STATUS_NOT_FOUND);
  40. return $response;
  41. }
  42. }