w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Redirect logged in users to home page when trying to access login page

It's probably because you have only IS_AUTHENTICATED_ANONYMOUSLY role for path ^/login set in security.yml. So then there is no authentication token allowed to be passed to LoginController.

You should try either to add ROLE_ADMIN also for ^/login path in the access_control, or include ^/login under ^/administration so it will become ^/administration/login.

And as condition in LoginController you should try to use

if($securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED'))
{
 return $this->redirect($this->generateUrl('public_homepage'));
}




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.