update
This commit is contained in:
parent
4365e63e3b
commit
37da66f18b
5 changed files with 47 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
controllers:
|
||||
resource: ../src/Controller/
|
||||
type: attribute
|
||||
|
||||
access_denied:
|
||||
path: /access-denied
|
||||
controller: App\Controller\ErrorController::accessDenied
|
||||
|
|
|
|||
19
src/Controller/ErrorController.php
Normal file
19
src/Controller/ErrorController.php
Normal 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', []);
|
||||
}
|
||||
}
|
||||
1
templates/error/access_denied.html.twig
Normal file
1
templates/error/access_denied.html.twig
Normal file
|
|
@ -0,0 +1 @@
|
|||
<h1>403</h1>
|
||||
20
templates/error/index.html.twig
Normal file
20
templates/error/index.html.twig
Normal 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 %}
|
||||
Loading…
Add table
Reference in a new issue