title: Prevent user redirect to login page if not logged in / Symfony3 FosUserBndl
body: <p>I'm using <a href="http://symfony.com/" rel="nofollow noreferrer">Symfony3</a> for a web application with the <a href="http://symfony.com/doc/master/bundles/FOSUserBundle/index.html" rel="nofollow noreferrer">FosUserBundle</a> for user management.</p>
  
  <p>I inserted in my app the login and register form as followed in my header.html.twig. This file (header) is inserted in my main file (base.html.twig) which means that it is inserted on almost all my pages. </p>
  
  <pre><code>  &lt;div class="modal fade" id="registerModal" role="dialog"&gt;
          {{ render(controller('UserBundle:Registration:Register', {'request': app.request})) }}
    &lt;/div&gt; 
  
    &lt;div class="modal fade" id="loginModal" role="dialog"&gt;
          {{ render(controller('UserBundle:Security:Login')) }}
    &lt;/div&gt; 
  </code></pre>
  
  <p>The problem is that when I try to access the home page <a href="http://localhost/baseurl/web/app_dev.php/" rel="nofollow noreferrer">http://localhost/baseurl/web/app_dev.php/</a> I am redirected to <a href="http://localhost/baseurl/web/app_dev.php/login" rel="nofollow noreferrer">http://localhost/baseurl/web/app_dev.php/login</a> <code>fos_user_security_login</code> (the FosUserBundle login route configured in the login_path of the security.yml.) 
  I don't understand how to configure and use the FUB in the case I have overrided and inserted the security_login form in the header</p>
  
  <p>My security.yml is as followed :</p>
  
  <pre><code>security:
  
      encoders:
          Symfony\Component\Security\Core\User\User: plaintext
          FOS\UserBundle\Model\UserInterface: sha512
  
      providers:
          fos_userbundle:
              id: fos_user.user_provider.username_email
  
      firewalls:
          dev:
              pattern: ^/(_(profiler|wdt)|css|images|js)/
              security: false
  
          main:
              pattern: ^/
              form_login:
                  login_path: fos_user_security_login
                  check_path: fos_user_security_check
                  provider: fos_userbundle
                  csrf_token_generator: security.csrf.token_manager
                  default_target_path: /
                  failure_path: /
              logout:
                  path:   /logout
                  target: /
              anonymous: true
              remember_me:
                  secret:   '%secret%'
                  lifetime: 604800 # 1 week in seconds
                  path:     /
  
      role_hierarchy:
          ROLE_SECRETAIRE: [ROLE_USER]
          ROLE_ADMIN: [ROLE_SECRETAIRE]
  
      access_control:
          - { path: ^/login, role: IS_AUTHENTICATED_ANONYMOUSLY }
          - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
          - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
          - { path: ^/admin/, role: ROLE_SECRETAIRE }
  </code></pre>
  
  <p>config.yml :</p>
  
  <pre><code># FOSUserBundle Configuration
  fos_user:
      db_driver:              orm
      firewall_name:          main
      user_class:             UserBundle\Entity\User
      use_listener:           true
      use_flash_notifications: true
      use_authentication_listener: true
      use_username_form_type: true
      model_manager_name:     null  # change it to the name of your entity/document manager if you don't want to use the default one.
      from_email:
          address:        xxx@gmail.com
          sender_name:    Gauthier
      profile:
          form:
              type:               FOS\UserBundle\Form\Type\ProfileFormType
              name:               fos_user_profile_form
              validation_groups:  [Profile, Default]
      change_password:
          form:
              type:               FOS\UserBundle\Form\Type\ChangePasswordFormType
              name:               fos_user_change_password_form
              validation_groups:  [ChangePassword, Default]
      registration:
          confirmation:
              enabled:    false
              template:   '@FOSUser/Registration/email.txt.twig'
          form:
              type:               UserBundle\Form\Type\RegistrationType
              name:               fos_user_registration_form
              validation_groups:  [Registration, Default]
      resetting:
          token_ttl: 86400
          email:
              template:   '@FOSUser/Resetting/email.txt.twig'
          form:
              type:               FOS\UserBundle\Form\Type\ResettingFormType
              name:               fos_user_resetting_form
              validation_groups:  [ResetPassword, Default]
      service:
          mailer:                 fos_user.mailer.default
          email_canonicalizer:    fos_user.util.canonicalizer.default
          username_canonicalizer: fos_user.util.canonicalizer.default
          token_generator:        fos_user.util.token_generator.default
          user_manager:           fos_user.user_manager.default
  </code></pre>
  
  <p>When I add a <code>die('ok');</code> in my controller matched with the route 'homepage' (<a href="http://localhost/baseurl/web/app_dev.php/" rel="nofollow noreferrer">http://localhost/baseurl/web/app_dev.php/</a>), I'm not redirected to <code>/login</code> but I have "ok" print on a white page. I don't understand where the redirection to /login is done</p>