Symfony-check

Check if your symfony application is ready for deployment

Symfony Check
"Login Required" error page
  • high
  • design

When a non authenticated user tries to access a page defined as secure in security.yml, symfony tries to access to the default/login action.

Login Required

To customize the "Login Required" page, add the executeLogin() method in the apps/frontend/modules/default/actions/actions.class.php file:

/**
 * Warning page for restricted area - requires credentials
 *
 */
public function executeLogin()
{
}

Then create the apps/frontend/modules/default/templates/loginSuccess.php template.

If you want, you can grab the original file and modify it.

Display the "Login Required" page to test it

  1. Pass in the production environment
  2. Logout: Use a logout link, or if you don't have one yet, go to your browser preferences and remove all the cookies related to your application domain.
  3. Try to access to a secure page.

Using an other module

If you want to use an other module, modify apps/frontend/config/settings.yml:

all:
  .actions:
    login_module: foo   # To be called when a non-authenticated user
    login_action: bar   # Tries to access a secure page

Make sure that in your module, the signin action is un-secure. In apps/frontend/modules/foo/config/security.yml:

bar:
  is_secure: false

Clear your cache.

php symfony cc

Read the related symfony documentation