Zend framework Zend Framework2使用Zfcuser&;Bjyauthorize路由

Zend framework Zend Framework2使用Zfcuser&;Bjyauthorize路由,zend-framework,zfcuser,bjyauthorize,Zend Framework,Zfcuser,Bjyauthorize,我是beginer zend框架程序员。我确实使用ZfcUser进行身份验证,使用Bjyauthorize进行授权。我必须确定用户类型:普通用户和管理员。所以我想做的是在身份验证后将用户路由到A页,将管理员路由到B页。 在Zfcuser配置文件中,没有这种可能性,我们只有这一行 'logout_redirect_route' => 'zfcuser/login', 如何为我的不同用户指定不同的路由?对我来说,你的问题与ZfcUser或BjyAuthorize无关:只需让用户和管理员进入

我是beginer zend框架程序员。我确实使用ZfcUser进行身份验证,使用Bjyauthorize进行授权。我必须确定用户类型:普通用户和管理员。所以我想做的是在身份验证后将用户路由到A页,将管理员路由到B页。 在Zfcuser配置文件中,没有这种可能性,我们只有这一行

 'logout_redirect_route' => 'zfcuser/login',

如何为我的不同用户指定不同的路由?

对我来说,你的问题与ZfcUser或BjyAuthorize无关:只需让用户和管理员进入你的控制器,然后根据用户角色进行调度

return $this->forward()->dispatch('MyModule\Controller\Index', array('action'=>'PageB'));

假设您在bjyauthorize中有一个要重定向到另一个路由的“admin”角色

在您的登录操作中,替换代码:

    if ($this->zfcUserAuthentication()->getAuthService()->hasIdentity()) {
        return $this->redirect()->toRoute($this->getOptions()->getLoginRedirectRoute());
    }
使用此代码:

    if ($this->zfcUserAuthentication()->getAuthService()->hasIdentity()) {
        $roles = $this->serviceLocator->get('BjyAuthorize\Provider\Identity\ProviderInterface')->getIdentityRoles();
        if (in_array('admin',$roles))
        {
            return $this->redirect()->toRoute('admin_route');
        } else {
            return $this->redirect()->toRoute('user_route');
        }
    }