CakePHP绕过Auth组件 [英] CakePHP Bypass Auth component

查看:48
本文介绍了CakePHP绕过Auth组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以绕过Auth组件并以管理员身份登录?我想测试我下载的插件,它要求您使用Auth组件以admin身份登录,但我不想设置users表等.

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.

推荐答案

您可以通过在控制器的beforeFilter()中使用以下代码来绕过身份验证:

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. :)

这篇关于CakePHP绕过Auth组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆