I applied the solution proposed on to many redirects login security.yml but I’m still getting the same error.
security.yaml
security:
encoders:
AppEntityUser:
algorithm: auto
providers
providers:
app_user_provider:
entity:
class: AppEntityUser
property: email
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
# Added this to the code in order to solve ERR_TOO_MANY_REDIRECTS issue
login_firewall:
pattern: ^/login$
anonymous: ~
main:
anonymous: true
lazy: true
provider: app_user_provider
guard:
authenticators:
- AppSecurityLoginFormAuthenticator
logout:
path: app_logout
remember_me:
secret: '%kernel.secret%'
lifetime: 604800 # 1 week in seconds
path: /
access_control:
- { path: ^/usuarios, roles: ROLE_ADMIN }
- { path: ^/usuario, roles: ROLE_ADMIN }
- { path: ^/incidencias, roles: ROLE_ADMIN }
- { path: ^/incidencia, roles: ROLE_ADMIN }
- { path: ^/modulos, roles: ROLE_ADMIN }
- { path: ^/modulo, roles: ROLE_ADMIN }
- { path: ^/categorias, roles: ROLE_ADMIN }
- { path: ^/categoria, roles: ROLE_ADMIN }
- { path: ^/generos, roles: ROLE_ADMIN }
- { path: ^/genero, roles: ROLE_ADMIN }
- { path: ^/estadisticas, roles: ROLE_ADMIN }
# - { path: ^/profile, roles: ROLE_USER }
I also removed a redirect from DefaultController.php in order to avoid extra redirects. However, I need to keep the redirect for the case in which the user is not found.
DefaultController.php
use SymfonyBundleFrameworkBundleControllerAbstractController;
use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentHttpFoundationRedirectResponse;
class DefaultController extends AbstractController
{
public function index()
{
//$request = Request::createFromGlobals();
//redirect to workinprogress again if the url target is not from workinprogress webpage
//if (!$request->query->get('from')) {
// $redirect = new RedirectResponse('/');
// $redirect->setTargetUrl('https://estudio-workinprogress.com/area-privada/');
// return $redirect;
//}
if($this->getUser() == null) {
return $this->redirectToRoute('app_login');
}
return $this->redirectToRoute('get_escenas');
}
}