zend-framework2zfcuserbjyauthorize

How to redirect to the login page with BjyAuthorize


I want to redirect some pages to the login page instead of page 403.

By default BjyAuthorize redirects everything to a 403 page. Is it possible to configure this behavior?

I found this: RedirectionStrategy. How do I use this?


Solution

  • Finally I got it.

    With version 1.2.* of BjyAuthorize, you simply add in config/autoload/bjyauthorize.global.php :

    return array(
        'bjyauthorize' => array(
            'unauthorized_strategy' => 'BjyAuthorize\View\RedirectionStrategy',
    //      [...]
        ),
    );
    

    And it will redirect you to the route configured in vendor/bjyoungblood/bjy-authorize/src/BjyAuthorize/View/RedirectionStrategy.php