Commit b1416f6e by Lech Sawon

security and fixtures

parent feaed35d
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
"twig/twig": "^2.12|^3.0" "twig/twig": "^2.12|^3.0"
}, },
"require-dev": { "require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.4",
"phpunit/phpunit": "^9.5", "phpunit/phpunit": "^9.5",
"symfony/browser-kit": "4.4.*", "symfony/browser-kit": "4.4.*",
"symfony/css-selector": "4.4.*", "symfony/css-selector": "4.4.*",
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -12,4 +12,5 @@ return [ ...@@ -12,4 +12,5 @@ return [
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true], Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true], Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
]; ];
...@@ -36,5 +36,7 @@ security: ...@@ -36,5 +36,7 @@ security:
access_control: access_control:
# - { path: ^/admin, roles: ROLE_ADMIN } # - { path: ^/admin, roles: ROLE_ADMIN }
# - { path: ^/profile, roles: ROLE_USER } # - { path: ^/profile, roles: ROLE_USER }
- { path: ^/room/*, roles: ROLE_USER } - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/ , roles: ROLE_USER }
...@@ -8,6 +8,7 @@ namespace App\Controller; ...@@ -8,6 +8,7 @@ namespace App\Controller;
use App\Entity\Category; use App\Entity\Category;
use App\Form\CategoryType; use App\Form\CategoryType;
use App\Repository\CategoryRepository; use App\Repository\CategoryRepository;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
...@@ -32,6 +33,7 @@ final class CategoryController extends AbstractController ...@@ -32,6 +33,7 @@ final class CategoryController extends AbstractController
/** /**
* @Route("/new", name="category_new", methods={"GET", "POST"}) * @Route("/new", name="category_new", methods={"GET", "POST"})
* @IsGranted("ROLE_ADMIN")
*/ */
public function new(Request $request): Response public function new(Request $request): Response
{ {
......
...@@ -3,11 +3,12 @@ declare(strict_types=1); ...@@ -3,11 +3,12 @@ declare(strict_types=1);
namespace App\Controller; namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
class LuckyController class LuckyController extends AbstractController
{ {
/** /**
* @Route("/lucky/number", name="app_lucky_number") * @Route("/lucky/number", name="app_lucky_number")
...@@ -16,8 +17,6 @@ class LuckyController ...@@ -16,8 +17,6 @@ class LuckyController
{ {
$number = random_int(0, 100); $number = random_int(0, 100);
return new Response( return $this->render('lucky/index.html.twig', ['luckyNumber'=> $number]);
'<html><body>Lucky number: '.$number.'</body></html>'
);
} }
} }
{
"doctrine/data-fixtures": {
"version": "1.5.1"
},
"doctrine/doctrine-fixtures-bundle": {
"version": "3.4",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "3.0",
"ref": "1f5514cfa15b947298df4d771e694e578d4c204d"
},
"files": [
"src/DataFixtures/AppFixtures.php"
]
}
}
...@@ -25,6 +25,17 @@ ...@@ -25,6 +25,17 @@
</head> </head>
<body> <body>
<div class="container"> <div class="container">
{% if app.user %}
<div class="mb-3">
<a href="{{ path('app_logout') }}">Logout</a>
</div>
{% else %}
<div class="mb-3">
<a href="{{ path('app_login') }}">Login</a>
</div>
{% endif %}
{% block body %}{% endblock %} {% block body %}{% endblock %}
</div> </div>
</body> </body>
......
{% extends 'base.html.twig' %}
{% block body %}
<h1>{{ luckyNumber }}</h1>
{% endblock %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment