0

こんにちは私は特定のコントローラーのユーザーを検証する方法を知りたいので、コントローラーのリソースにアクセスする前に特定のユーザーが認証されていることを確認できますか?

4

2 に答える 2

1

Zend_AuthおよびZend_Aclコンポーネントを確認する必要があります。

Zend_Auth is responsible for assigning and managing authentication of the user.

Zend_Acl is responsible for managing different permissions and roles for different resources.

これは、Zend_Authを実装する方法を説明するチュートリアルです。

http://akrabat.com/zend-auth-tutorial/

以下のチュートリアルでは、Zend_Auth/Zend_Aclについて説明しています。

http://devzone.zend.com/844/zend_acl-zend_auth-example-scenario/

于 2012-07-25T03:40:46.533 に答える
0

コントローラフォルダ内の特定のコントローラについて、CashoutControllerがあるとしましょう。ユーザーがこのコントローラーにアクセスする前に、カスタムライブラリを使用して以下のようにユーザーを認証します。

<?php
 class CashoutController extends Zc_Controller_Action_User
 {
  public function init()
  {
    /* Initialize action controller here */
    parent::init();
  }
    // rest code goes here
 }

ここで、新しいライブラリ名Zcを定義しました

   <?php
   class Zc_Controller_Action_User extends Zc_Controller_Action
{ 
public function init()
{
    parent::init();
    $this->validateAccess();
}

private function validateAccess()
{
    $auth = Zend_Auth::getInstance();

    if (is_null($auth->getIdentity())) {
        $this->_helper->redirector('index', 'index');
    }
}
    }

ここで、コントローラーアクションライブラリを次のように定義します。

<?php

class Birdtoldme_Controller_Action extends Zend_Controller_Action
{

 }

これがあなたにとって有益であったことを願っています。

于 2012-07-25T03:39:33.547 に答える