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?
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?
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
Check this UnauthorizedStrategy class by Rob Allen: https://gist.github.com/akrabat/3783912 When using this class you have to configure BjyAuthorize to use it, like this:
return array(
'bjyauthorize' => array(
'unauthorized_strategy' => 'Application\View\UnauthorizedStrategy',
),
);
Edit: Don't forget to add the relevant service manager config to allow the service manager to instantiate the UnauthorizedStrategy object:
'service_manager' => array(
'invokables' => array(
'Application\View\UnauthorizedStrategy' => 'Application\View\UnauthorizedStrategy',
),
I'm also trying and I came across this page: https://github.com/bjyoungblood/BjyAuthorize/issues/24
This way, you can extend the UnauthorizedStrategy.