Search code examples
symfonyauthenticationproduction-environment

Symfony2: doesn't redirect to login when not logged


I am developing an application in Symfony2 and I have a problem with redirecting to login page when user isn't logged in. Instead of redirecting, appears a blank page. This happens in my production environment and when the application is not on debug mode. In my development environment, the redirection works on debug and non-debug mode, and in the production environment it works in debug mode.

Any idea why this is happening?

This is the security.yml file:

jms_security_extra:
    secure_all_services: false
    expressions: true

security:
    encoders:
        W_Encuestas\EncuestasBundle\Entity\Usuario: 
            algorithm: sha512
            encode-as-base64: true
            iterations: 10

    role_hierarchy:
        ROLE_SUPER_ADMIN: [ROLE_ADMIN]
        ROLE_ADMIN: [ROLE_USER]

    providers:
        main:
            entity:
                class: W_Encuestas\EncuestasBundle\Entity\Usuario
                property: mail

    firewalls:
        secured_area:
            pattern: /.*
            form_login:
                login_path: /siteIntranet/login
                check_path: /check
                remember_me: true
                default_target_path: /siteIntranet/home
            logout:
                path: /logout
                target: /siteIntranet/login
            remember_me:
                key: "%secret%"
                lifetime: 1800
                path: /.*
                domain: ~
            security: true
            anonymous: true

    access_control:
        - { path: ^/siteIntranet/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/siteIntranet/home , roles: ROLE_USER }
    # ....

Solution

  • It just was the cache. And in case anyone has the same problem I had to delete it:

    On UNIX systems, the cache and logs are created with permissions that prevent removal. To prevent this from happening, add an instruction "umask" in "app/console", "web/app.php" and "web/app_dev.php," as paragraph "Setting up Permissions" in the following link:

    http://symfony.com/doc/current/book/installation.html