0

私は Web サイトで作業しています。履歴書の一部のユーザーには、ログインしたユーザーのみがダウンロードできる記事がいくつかあります。ログイン アクションまたは preDispatch() を変更して、ゲスト ユーザーが記事をダウンロードするためのセッションを設定したいと考えています。

誰かがそれを行う方法を教えてもらえますか、または参照リンクをいくつか教えてもらえますか?

ここに私の preDispatch() があります:

   public function preDispatch()
    {
        $userInfo=$this->_auth->getStorage()->read();
        $identity= $this->_auth->getIdentity();
        if(!$this->_auth->hasIdentity())
        {

            return $this->_helper->redirector('login','login');


        }
        if(!isset($userInfo["member_id"]) || strlen($userInfo["member_id"])==0)
        {
            return $this->_helper->redirector('forbidden','login');
        }
        $this->_accessType=2;

    }
4

2 に答える 2

0

ゲストユーザーに異なるアクセシビリティが必要な場合は、Zend_Aclを確認する必要があります。これがあなたを助けるかもしれない2つのリンクです:http://framework.zend.com/manual/1.12/en/learning.multiuser.authorization.html、ZendAuthACL

于 2012-11-28T13:44:06.760 に答える
0

これは私のために働いた:

public function _getGuestPremision()
{
    $_acl = new Zend_Acl();
    $_acl->add(new Zend_Acl_Resource('ref'));
    $_acl->add(new Zend_Acl_Resource('downloadendnote'),'ref');
    $_acl->add(new Zend_Acl_Resource('downloadmed','ref');
    $_acl->add(new Zend_Acl_Resource('downloadris','ref');

    $_acl->addRole(new Zend_Acl_Role('guest'));

    $_acl->allow('guest','ref','downloadendnote');
    $_acl->allow('guest','ref','downloadmed');
    $_acl->allow('guest','ref','downloadris');
    return $_acl ;
}
public function preDispatch()
{
    $this->$_gAcl = _getGuestPremision();

    if(!$this->_auth->hasIdentity())
    {

        if(!$_gAcl->isAllowed('guest','ref','downloadendnote'))
        {
            return $this->_helper->redirector('login','login');
        }   
        if(!$_gAcl->isAllowed('guest','ref','downloadmed'))
        {
            return $this->_helper->redirector('login','login');
        }   
        if(!$_gAcl->isAllowed('guest','ref','downloadris'))
        {
            return $this->_helper->redirector('login','login');
        }   
    }
    if(!isset($userInfo["member_id"]) || strlen($userInfo["member_id"])==0)
    {
        return $this->_helper->redirector('forbidden','login');
    }
    $this->_accessType=2;

}
于 2012-11-29T05:30:09.887 に答える