Since you are using FOSUserBundle, the rendering of the login form happens in . SecurityController::renderLogin()
The decision is based on:
- override SecurityController
- adding validation for a role
IS_AUTHENTICATD_ANONYMOUSLY - redirect the user to another page if the role is not found
, , FOSUserBundle, User Entity.
, YourUserBundle src/Your/Bundle/UserBundle.
( ) SecurityController
vendor/friendsofsymfony/user-bundle/src/FOS/UserBundle/Controller/SecurityController.php
to ( , FOSUserBundle)
src/Your/Bundle/UserBundle/Controller/SecurityController.php
use RedirectResponse renderLogin() :
use Symfony\Component\HttpFoundation\RedirectResponse;
protected function renderLogin(array $data)
{
if (false === $this->container->get('security.context')->isGranted('IS_AUTHENTICATED_ANONYMOUSLY')) {
return new RedirectResponse('/', 403);
}
$template = sprintf('FOSUserBundle:Security:login.html.%s', $this->container->getParameter('fos_user.template.engine'));
return $this->container->get('templating')->renderResponse($template, $data);
}
Update
security.context security.authorization_checker.
http://symfony.com/blog/new-in-symfony-2-6-security-component-improvements