我已经设置了bjyoungblood/bjy-authorize模块,但是我正在403为每个URL 收到"访问被拒绝"错误,除了home路由中配置的那个.
我module.byjauthorize.global.php看起来如下:
'bjyauthorize' => array(
'guards' => array(
'BjyAuthorize\Guard\Controller' => array(
array('controller' => 'index', 'action' => 'index', 'roles' => array('guest','user')),
array('controller' => 'index', 'action' => 'stuff', 'roles' => array('user')),
array('controller' => 'zfcuser', 'roles' => array()),
//backend
array('controller' => 'Application\Controller\Index', 'roles' => array('admin')),
array('controller' => 'MyModule\MyEntity\MyEntity', 'roles' => array('admin')),
),
'BjyAuthorize\Guard\Route' => array(
array('route' => 'zfcuser', 'roles' => array('user')),
array('route' => 'zfcuser/logout', 'roles' => array('user')),
array('route' => 'zfcuser/login', 'roles' => array('guest')),
array('route' …Run Code Online (Sandbox Code Playgroud) 我正在使用Zend Framework 2和ZfcUser,BjyAuthorize和Doctrine作为数据库.到目前为止,注册等工作非常顺利.我的问题是,注册用户没有分配角色,所以我想在注册期间向用户添加角色"user".
我想我可以将它附加到"注册"事件,但我不知道该怎么做.
我希望有一个人可以帮助我 ...
(我使用本教程设置zfcuser等http://samminds.com/2013/03/zfcuser-bjyauthorize-and-doctrine-working-together/)
public function onBootstrap(MvcEvent $e)
{
$zfcServiceEvents = $e->getApplication()->getServiceManager()->get('zfcuser_user_service')->getEventManager();
$zfcServiceEvents->attach('register', function($e) {
$user = $e->getParam('user');
// probably the role must be added here, with $user->addRole();
// but how do i get the user Role Entity to add from DB?
});
Run Code Online (Sandbox Code Playgroud) 我正在使用BjyAuthorize和Zend Framework2来实现授权,并且能够成功地集成来自数据库的角色.现在我想从数据库表中获取规则和保护.我怎样才能做到这一点?
我想将一些页面重定向到登录页面而不是页面403.
默认情况下,BjyAuthorize将所有内容重定向到403页面.是否可以配置此行为?
我发现了这个:RedirectionStrategy.我该如何使用它?
我使用zf2与这两个模块(zfc-user,bjyauthorize),我想从我的行动中获取用户角色
我正在使用,bjyauthorize而且我对现有用户非常有用.我现在需要动态添加用户.
我可以在表格之间设置连接User和Role手动连接UserRoleLinker但是我对新用户的设置方式如何呢?也许我错过了一些微不足道的事情?
谢谢!