Git Product home page Git Product logo

Comments (11)

bjyoungblood avatar bjyoungblood commented on May 18, 2024

Personally, I override view/error/403.phtml in my application code, I display a short error message and then do this: <?php $this->headMeta('5;URL=/login', 'refresh', 'http-equiv'); ?> (provided you are already using the HeadMeta helper in your layout script).

This method allows you to do some custom logic before redirecting, since you may not want to redirect authenticated and unauthenticated users to the same route.

from bjyauthorize.

gmuehl avatar gmuehl commented on May 18, 2024

Works fine, though, i personally prefer a Header-Redirect ;)

from bjyauthorize.

bjyoungblood avatar bjyoungblood commented on May 18, 2024

I added some code to make the view strategy configurable, which will allow you to modify the response. You can extend BjyAuthorize\View\UnauthorizedStrategy and modify the behavior of the onDispatchError method to suit your needs (i.e. add a header redirect).

Just make sure the class is set up by the service manager and use the following configuration option:

<?php

return array(
    'bjyauthorize' => array(
        'unauthorized_strategy' => 'YourModule\View\UnauthorizedStrategy',
    ),
);

from bjyauthorize.

surjit avatar surjit commented on May 18, 2024

can you pleas help me , how to create setup class service manager.

i'm getting this message

Fatal error: Uncaught exception 'Zend\ServiceManager\Exception\ServiceNotFoundException' with message 'Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for ZfcUser\View\UnauthorizedStrategy' in C:\xampp\htdocs\caleb\zend\vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php:424 Stack trace: #0 C:\xampp\htdocs\caleb\zend\module\BjyAuthorize\Module.php(23): Zend\ServiceManager\ServiceManager->get('ZfcUser\View\Un...') #1 [internal function]: BjyAuthorize\Module->onBootstrap(Object(Zend\Mvc\MvcEvent)) #2 C:\xampp\htdocs\caleb\zend\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(468): call_user_func(Array, Object(Zend\Mvc\MvcEvent)) #3 C:\xampp\htdocs\caleb\zend\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(208): Zend\EventManager\EventManager->triggerListeners('bootstrap', Object(Zend\Mvc\MvcEvent), Array) #4 C:\xampp\htdocs\caleb\zend\vendor\zendframework\zendframework\library\Zend\Mvc\Application.php(1 in C:\xampp\htdocs\caleb\zend\vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php on line 424

from bjyauthorize.

vinigarcia87 avatar vinigarcia87 commented on May 18, 2024

@surjit, you must include this:

public function getServiceConfig()
{
    return array(
        'factories' => array(
            'Admin\View\UnauthorizedStrategy' => function ($sm) {
                $template = $sm->get('BjyAuthorize\Service\Authorize')->getTemplate();
                $strategy = new View\UnauthorizedStrategy;
                $strategy->setTemplate($template);
                return $strategy;
            },
        ),
    );
}

In Module.php.

from bjyauthorize.

vinigarcia87 avatar vinigarcia87 commented on May 18, 2024

remind to change 'Admin\View\UnauthorizedStrategy' by your correct name...

from bjyauthorize.

webdevilopers avatar webdevilopers commented on May 18, 2024

A view strategy to redirect to login page on auth failure by Rob Allen:
https://gist.github.com/akrabat/3783912

from bjyauthorize.

Ocramius avatar Ocramius commented on May 18, 2024

@webdevilopers I'd love to merge such a strategy into the repository if someone wrote tests for it :)

from bjyauthorize.

webdevilopers avatar webdevilopers commented on May 18, 2024

I started using ZF2 and UnitTests recently and I guess I'm no help yet! :( Maybe Mr. Rob Allen @akrabat will help us out! :)

from bjyauthorize.

miqueiasrafael avatar miqueiasrafael commented on May 18, 2024

someone can tell me how can I solve this problem please? An alias "zfcuser Zend_Db_Adapter" was requested but the service could be found.

from bjyauthorize.

miqueiasrafael avatar miqueiasrafael commented on May 18, 2024

@bjyoungblood It would be great if you had a video BjyAuthorize because it would help a lot! So googled several people downloaded and tried to use the package but on the way encountered several problems when configuring or installing because even the deprecated

from bjyauthorize.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.