我的 Controller 中有以下代码片段:
public function beforeFilter() {
$this->autoRender = false;
...
$this->Auth->allow('email');
}
public function email() {
...
$this->show();
...
}
public function show() {
...
}
我的
show
操作需要身份验证,但不需要email
。当我的hadoop作业完成时,
email
操作代表接受jobEndNotifier的通知,因此我无法在该页面上进行身份验证,因为hadoop将访问它。(https://hadoop.apache.org/docs/r1.2.1/api/org/apache/hadoop/mapred/JobEndNotifier.html)
我的
show
操作基本上会生成并可视化已完成的hadoop作业的报告,当我的作业完成后,我想在系统中自动生成(缓存)报告,因此稍后用户访问该页面时,它将从缓存中加载并会更快。这就是我从show
Action 调用email
Action 的原因。当然,默认情况下,我无需登录即可访问
email
操作,但是当我从show
调用email
操作时,它将重定向到首页,提示您必须登录。简而言之:如果我从
show
Action 调用email
Action ,是否可以设置身份验证?由于未呈现页面,因此仅进行计算。提前致谢。
最佳答案
按照您的逻辑,
$ this-> Auth-> allow('email');
绕过电子邮件方法的身份验证,
您可以通过相同的方式设置从电子邮件功能中跳过显示,例如
public function beforeFilter() {
$this->autoRender = false;
...
$this->Auth->allow('email');
}
public function email() {
...
$this->Auth->allow('show'); /* allow show here **/
$this->show();
...
}
public function show() {
...
}
关于php - 禁用同一 Controller 中给定操作的身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24240801/