0

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. enter image description here And when I click on Logs I have:

enter image description here My config is :

<?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 have this error : enter image description here

I removed the twig and I put only PHP like that : engines: ['php'] [enter image description here]4

I can't found any solution. How can I resolve this problem. Thanks a lot

1 Answer 1

2

this is probably because your account that you want to log in with doesn't have the ROLE_ADMIN, if you use this command: php bin/console fos:user:promote your username ROLE_ADMIN, and relog your account you should be able to.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.