如何更改*\vendor\bjyoungblood\bjy-authorize\src\BjyAuthorize\View\RedirectionStrategy.php
中的类RedirectionStrategy以更改$redirectRoute
属性的值?
首先,我关注此帖:How to redirect to the login page with BjyAuthorize
谢谢!
答案 0 :(得分:3)
我找到了:https://github.com/bjyoungblood/BjyAuthorize/blob/master/docs/unauthorized-strategies.md
namespace MyApp;
use BjyAuthorize\View\RedirectionStrategy;
class Module
{
public function onBootstrap(EventInterface $e) {
$application = $e->getTarget();
$eventManager = $application->getEventManager();
$strategy = new RedirectionStrategy();
// eventually set the route name (default is ZfcUser's login route)
$strategy->setRedirectRoute('my/route/name');
// eventually set the URI to be used for redirects
$strategy->setRedirectUri('http://example.org/login');
$eventManager->attach($strategy);
}
}
这是有效的!
答案 1 :(得分:0)
添加bjyauthorize.global.php
'unauthorized_strategy' => 'BjyAuthorize\View\RedirectionStrategy'
然后在module.php中
use BjyAuthorize\View\RedirectionStrategy;
$strategy = new RedirectionStrategy();
$strategy->setRedirectRoute('zfcuser/login');
$eventManager->attach($strategy);