This commit is contained in:
ExostFlash 2023-12-05 14:59:12 +01:00
parent 4365e63e3b
commit 37da66f18b
5 changed files with 47 additions and 2 deletions

View file

@ -21,6 +21,7 @@ security:
check_path: app_user_login
logout:
path: app_user_logout
access_denied_url: /access-denied
# activate different ways to authenticate
# https://symfony.com/doc/current/security.html#the-firewall

View file

@ -1,3 +1,7 @@
controllers:
resource: ../src/Controller/
type: attribute
resource: ../src/Controller/
type: attribute
access_denied:
path: /access-denied
controller: App\Controller\ErrorController::accessDenied

View file

@ -0,0 +1,19 @@
<?php
// src/Controller/ErrorController.php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
#[Route('/error', name: 'access_error')]
class ErrorController extends AbstractController
{
#[Route('/403', name: 'access_denied')]
public function accessDenied(): Response
{
return $this->render('error/access_denied.html.twig', []);
}
}

View file

@ -0,0 +1 @@
<h1>403</h1>

View file

@ -0,0 +1,20 @@
{% extends 'base.html.twig' %}
{% block title %}Hello ErrorController!{% endblock %}
{% block body %}
<style>
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
</style>
<div class="example-wrapper">
<h1>Hello {{ controller_name }}! ✅</h1>
This friendly message is coming from:
<ul>
<li>Your controller at <code><a href="{{ '/home/exostflash/McDoPlus/src/Controller/ErrorController.php'|file_link(0) }}">src/Controller/ErrorController.php</a></code></li>
<li>Your template at <code><a href="{{ '/home/exostflash/McDoPlus/templates/error/index.html.twig'|file_link(0) }}">templates/error/index.html.twig</a></code></li>
</ul>
</div>
{% endblock %}