Comments (11)
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.
Works fine, though, i personally prefer a Header-Redirect ;)
from bjyauthorize.
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.
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.
@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.
remind to change 'Admin\View\UnauthorizedStrategy' by your correct name...
from bjyauthorize.
A view strategy to redirect to login page on auth failure by Rob Allen:
https://gist.github.com/akrabat/3783912
from bjyauthorize.
@webdevilopers I'd love to merge such a strategy into the repository if someone wrote tests for it :)
from bjyauthorize.
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.
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.
@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)
- Controller Guard action name HOT 1
- Super role full access HOT 3
- [Question] Why is the User table named "users" and not "user"? HOT 20
- Guards should conform the other onRoute/onDispatch listeners
- Can't use flashMessenger on RedirectionStrategy HOT 1
- Assign diferent roles to one user HOT 1
- Exception UnAuthorizedException thrown instead of error/403 template HOT 7
- Problem when not defined guard to access
- Action get have no permissions HOT 1
- Fatal error: unable to fetch or create an instance for BjyAuthorize\Config' HOT 1
- Strange behaviour in role assigning HOT 1
- Get current user role
- Unauthorized is a word and should not be CamelCased as if it were two words HOT 1
- isAllowed only works after reload HOT 1
- Not working with zendframework/zend-eventmanager (2.6.2) HOT 1
- RedirectionStrategy doesnt work on latest zf2 HOT 1
- Question: How can I load roles from database withouth using doctrine?
- Is this module discontinued? HOT 14
- getting an error during phpunit testing.
- Use BjyAuthorize with ZF3 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bjyauthorize.