ACL - Where to configure custom userModel for authorize?

回眸只為那壹抹淺笑 提交于 2019-12-11 03:25:12

问题


I'm having Player instead of default User model for my Auth. I recently configured ACL for my app and while trying to do testing by return false in my isAuthorized($player) function, the following error occured:

AclNode::node() - Couldn't find Aro node identified by
Array ( [Aro0.model] => User [Aro0.foreign_key] => 1 )

Isn't the Aro0.model suppose to be Player? I can't find where to change for Auth->authorize. Auth-authenticate works fine as I manage to login since there is a userModel option allow me to specify a custom Model for user login.

Here's My AppController

class AppController extends Controller
{
    public $components = array(
        'Session',
        'Acl',
        'RequestHandler',
        'Auth' => array(

            'authorize' => array(
                'controller',
                'Actions' => array('actionPath' => 'controllers'),
            ),

            'authenticate' => array(
                'Form' => array(
                    'userModel' => 'Player',
                    'fields' => array('username' => 'email', 'password' => 'password'),
                    )
                )
            ),
        );
    public $helpers = array('Html', 'Form', 'Session');

    function isAuthorized($player)
    {
        //var_dump($player); die;
        return false;
        return $this->Auth->loggedIn();
    }

}

回答1:


Solved. it is to append userModel together with actionPath.

$this->Auth->authorize = array(
    AuthComponent::ALL => array('actionPath' => 'controllers/', 'userModel' => 'Player'),
    'Actions',
    'Controller'
);


来源:https://stackoverflow.com/questions/12967707/acl-where-to-configure-custom-usermodel-for-authorize

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!