开发者

CakePHP Bypass Auth component

Is it possible to bypass the Auth component and be logged in as an administrator? I want to test a plugin I downloaded and it requires you to be logged in using the Auth component as admin but I don't开发者_如何转开发 want to setup a users table etc.


You can bypass authentication by using the following code in your beforeFilter() of your controller:

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

If you want to toggle only specific actions:

function beforeFilter() {
    parent::beforeFilter();
    $this->Auth->allow('admin_index', 'admin_view');
}

Now, you won't have to log in to access these pages. :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜