我已经尝试过
$this->Auth->allow()
in beforeFilter()
但是,我需要添加整个 Controller 作为异常(exception),即它需要公开并且不需要用户登录。
只是一种执行$this->Auth->allow(every-function-in-this-controller)
的快捷方式
答案?
编辑:
我有这个:
<?php
App::uses('AppController','Controller');
class AllzonesController extends AppController {
public function __beforeFilter() {
parent::beforeFilter();
$this->Auth->allow('index');
}
public function index() {
$this->layout = 'main';
$this->set('Hello',"Hello world");
}
}
正在调用Auth-login()
最佳答案
你提出的是你想做的合适的方式
public function beforeFilter() {
$this->Auth->allow();
}
阅读API docs
Takes a list of actions in the current controller for which authentication is not required, or no parameters to allow all actions.
因此没有参数的函数应该允许普通用户(未登录)访问该 Controller 的每个操作。
编辑:
抱歉,错过了您标签中的版本引用。 In here它说
$this->Auth->allow('*');
是 Cake 2.0(和以前的版本,如@mark 所述)的合适方式
关于php - 在 CakePHP Auth 中允许整个 Controller 并且 allow() 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17454792/