http://blog.test/register and http://blog.test/login works well, so when I access from http://blog.test/admin I am redirected to http://blog.test/login and
and when I log in i have this error : Access Denied.
And when I click on Logs I have:
<?php
// src/Entity/User.php
namespace App\Entity;
use FOS\UserBundle\Model\User as BaseUser; use Doctrine\ORM\Mapping as ORM;
/** * @ORM\Entity * @ORM\Table(name="fos_user") */ class User extends BaseUser { /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ protected $id;
public function __construct()
{
parent::__construct();
// your own logic
}
}
config\packages\framework.yaml
framework:
templating:
engines: ['twig', 'php']
config\packages\security.yaml
security:
encoders:
FOS\UserBundle\Model\UserInterface: bcrypt
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
in_memory: { memory: null }
fos_userbundle:
id: fos_user.user_provider.username_email
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
pattern: ^/
user_checker: security.user_checker
form_login:
provider: fos_userbundle
csrf_token_generator: security.csrf.token_manager
logout: true
anonymous: true
# activate different ways to authenticate
# https://symfony.com/doc/current/security.html#firewalls-authentication
# https://symfony.com/doc/current/security/impersonating_user.html
# switch_user: true
# Easy way to control access for large sections of your site
# Note: Only the *first* access control that matches will be used
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin, role: ROLE_ADMIN }
config\routes\fos_user.yaml
fos_user:
resource: "@FOSUserBundle/Resources/config/routing/all.xml"
I searched everywhere and I had no solution, I even tried to remove the templating: engines: ['twig', 'php']
I removed the twig and I put only PHP like that : engines: ['php']
[]4
I can't found any solution. How can I resolve this problem. Thanks a lot