2

プロファイルベースのアプリケーションを構築しています。ここにある単純な acl 制御アプリケーション チュートリアルを使用しようとしています: http://book.cakephp.org/2.0/en/tutorials-and-examples/simple-acl-controlled-application/simple-acl-managed-application。 html、グループと権限を作成します。別のユーザーとしてログインしたときに機能する権限を取得する際に問題が発生しました。管理者、マネージャー、およびユーザー グループがあります。ACO と ARO を設定し、各グループに権限を追加しました。これが私の

class AppController extends Controller {

    public $components = array(
        'Acl',
        'Auth'=>array(
            'loginRedirect'=>array('controller'=>'users', 'action'=>'index'),
            'logoutRedirect'=>array('controller'=>'users', 'action'=>'index'),
            'authError'=>'You cannot access that page',
            'authorize'=>array('actionPath' => 'controllers')
        ),
        'Session'
    );

    public function isAuthorized($user) {
        return true;
    }

    public function beforeFilter() {
        $this->Auth->authorize = array(
            'Actions' => array(
                'userModel' => 'User',
                'actionPath' => 'users'
            )
        );

        $this->Auth->allow('display');

        $this->set('logged_in', $this->Auth->loggedIn());
        $this->set('current_user', $this->Auth->user());

    }

}

UserController.php

class UsersController extends AppController {

    public function beforeFilter() {
        parent::beforeFilter();
        $this->Auth->allow('view');
    }



    public function login() {
        if ($this->request->is('Post')) {
            if ($this->Auth->login()) {
                $this->redirect($this->Auth->redirect());
            } else {
                $this->Session->setFlash('Your username/password combination was incorrect');
            }
        }
    }

    public function logout() {
        $this->redirect($this->Auth->logout());
    }

私が今得ているエラーは次のとおりです。

Warning (512): DbAcl::check() - Failed ARO/ACO node lookup in permissions check. Node references:
Aro: Array
Permission::check() - CORE/Cake/Model/Permission.php, line 94
DbAcl::check() - CORE/Cake/Controller/Component/Acl/DbAcl.php, line 73
AclComponent::check() - CORE/Cake/Controller/Component/AclComponent.php, line 109
ActionsAuthorize::authorize() - CORE/Cake/Controller/Component/Auth/ActionsAuthorize.php, line 40
AuthComponent::isAuthorized() - CORE/Cake/Controller/Component/AuthComponent.php, line 412
AuthComponent::startup() - CORE/Cake/Controller/Component/AuthComponent.php, line 336
ObjectCollection::trigger() - CORE/Cake/Utility/ObjectCollection.php, line 132
call_user_func - [internal], line ??
CakeEventManager::dispatch() - CORE/Cake/Event/CakeEventManager.php, line 248
Controller::startupProcess() - CORE/Cake/Controller/Controller.php, line 671
Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 184
Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 162
[main] - APP/webroot/index.php, line 109

何らかの理由で、アクセス許可にアクセスできません。そして、これを修正する解決策を見つけることができないようです。どんな助けでも素晴らしいでしょう!前もって感謝します!

4

2 に答える 2

2

これらのエラーは通常、コントローラーに関数/メソッドを追加したが、acos および aros_acos テーブルを再設定しなかったことが原因です。

acos テーブルにデータを入力する必要があります

./Console/cake AclExtras.AclExtras aco_sync

http://book.cakephp.org/2.0/en/tutorials-and-examples/simple-acl-managed-application/part-two.html

データが入力されたら、この新しいメソッドの権限を aros_acos テーブルに割り当てる必要があります

$this->Acl->allow($group, 'controllers/Posts/myNewCustomMethod');

その後、initDB 関数を再度実行します。チュートリアルはステップごとに非常に明確です。

于 2013-06-21T07:25:03.200 に答える
0

msj に警告しています。チェックするためだけに: この行を関数 beforeFilter に入れてチェックします。

public function beforeFilter() {
    parent::beforeFilter();
    // For CakePHP 2.0
    $this->Auth->allow('*');
    // For CakePHP 2.1 and up
    $this->Auth->allow();
    // or you can put the view
    $this->Auth->allow('index','edit','add','login','delete');
}
于 2015-06-27T21:53:19.440 に答える