Question

How can I override the class RedirectionStrategy in *\vendor\bjyoungblood\bjy-authorize\src\BjyAuthorize\View\RedirectionStrategy.php in order to change the value of $redirectRoute attribute ?

http://pastebin.com/pPKsZcC5

First I follow this post : How to redirect to the login page with BjyAuthorize

Thank you!!

Was it helpful?

Solution

I found : 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);
    }
}

It's works!

OTHER TIPS

add in bjyauthorize.global.php

'unauthorized_strategy' => 'BjyAuthorize\View\RedirectionStrategy'

and then in module.php

        use BjyAuthorize\View\RedirectionStrategy;
        $strategy = new RedirectionStrategy(); 
        $strategy->setRedirectRoute('zfcuser/login'); 
        $eventManager->attach($strategy); 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top