【问题标题】:Cakephp Auth component malfunctioningCakephp Auth 组件故障
【发布时间】:2011-07-31 01:07:07
【问题描述】:

我在 ovh 主机上的 cakephp 中的身份验证组件遇到了问题。

当我登录时,没有设置会话变量: print_r($this_session) 只显示:

Array ( [Config] => Array ( [userAgent] => [time] => 1302122401 [timeout] => 10 ) )

这个问题的奇怪之处在于,有时它可以正常工作……我过去常常在我家正确连接,而不是我的工作。

这是我使用的代码。这真的很简单。 一个 app_controller :

<?php
class AppController extends Controller {
        var $components = array("Session","Auth");
        function beforeFilter() {
                $this->Auth->fields = array('username' => 'name', 'password' => 'password');
                $this->Auth->loginAction = array('action' => 'login');
        $this->Auth->loginRedirect = array('controller' => 'discs', 'action' => 'hello');
        $this->Auth->logoutRedirect = '/';
                $this->Auth->loginError = 'Invalid name / password combination.  Please try again';
        }
}

?>

在用户控制器中:

function login() {
           }

    function logout() {
    $this->redirect($this->Auth->logout());
    }

我尝试修改会话配置: - 尝试 php 或 cake 管理 - 尝试从低到中的安全级别 - 试图更改会话 cookie 名称 - 尝试将 checkAgent 设置为 false。

有什么想法吗?

【问题讨论】:

  • 尝试从过滤器之前暂时删除所有内容并尝试一下。如果有效。
  • 如果我从父过滤器中删除所有内容,它不会记录我。如果我只是让 Auth->fields 设置,则行为与以前相同。

标签: session cakephp cakephp-1.3 authentication


【解决方案1】:

我不确定,但我猜您的代码已经正确。 我注意到文件名“user_controller”。那是 user_controller 而不是 users_controller? cakephp 中的命名约定对于我们防止此类错误非常重要。最后,尝试删除$this-&gt;Auth-&gt;loginAction = array('action' =&gt; 'login');

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-25
    • 2011-09-09
    • 2011-05-09
    • 1970-01-01
    相关资源
    最近更新 更多