使用表单登录不能在cakephp上运行

时间:2015-09-11 00:00:36

标签: forms cakephp login server

我是cakephp的新手。我尝试运行登录表单,但它总是返回false给我。当我从用户注册表单手动登录时,一切正常。我在服务器1&上开发了我的应用程序。 1,一切正常。由于我在客户端的服务器上安装了服务器HostPapa,我的登录问题就出现了。你知道发生了什么吗?我尝试了一切都没有成功。

以下是登录操作:

public function candidat_login() {

    if ($this->Auth->user('id')) {
        return $this->redirect('/candidat/users/profil/');
    }

    if ($this->request->is('post')) {

        if ($this->Auth->login()&&$this->Auth->user('role')==false) {
            return $this->redirect($this->Auth->redirectUrl());
        } 
    }

    if ($this->request->is('post')) {
        if ($this->Auth->login() && $this->Auth->user('role')==true) {
         return $this>redirect(array('action' => 'dashboard', 'admin' => true));
        } else {
            $this->Session->setFlash(__("Nom d'utilisateur ou mot de passe invalide, réessayer"));
        }
    } 
}

我做错了什么? 请注意,在1& 1服务器上一切正常。请帮帮我

编辑1

我调试$ this-> Auth-> login()就像这样

public function candidat_login() {

 if ($this->Auth->user('id')) {
 return $this->redirect('/candidat/users/profil/');
 }
if ($this->request->is('post')) {
  debug($this->Auth->login());
  die();
    if ($this->Auth->login()&&$this->Auth->user('role')==false) {
        return $this->redirect($this->Auth->redirectUrl());
    } 
}
  if ($this->request->is('post')) {
    if ($this->Auth->login()&&$this->Auth->user('role')==true) {
        return $this->redirect(array('action'=>'dashboard','admin'=>true));
    } else {
        $this->Session->setFlash(__("Nom d'utilisateur ou mot de passe invalide, réessayer"));
      }
    }
 }

我得到了这个: 警告(4096):传递给Hash :: get()的参数1必须是类型数组,给定字符串,在第670行的/home/afrik953/public_html/concours/lib/Cake/Controller/Component/AuthComponent.php中调用并定义[CORE / Cake / Utility / Hash.php,第45行] 警告(4096):传递给Hash :: get()的参数1必须是类型数组,给定字符串,在第670行的/home/afrik953/public_html/concours/lib/Cake/Controller/Component/AuthComponent.php中调用并定义[CORE / Cake / Utility / Hash.php,第45行] /app/Controller/UsersController.php(第132行) 真正 我使用的是simplepasswordhash。你知道这是什么意思吗? 对不起,我的英语不好 这是我的用户模型beforesave action:

public function beforeSave($options = array()) {
if (isset($this->data[$this->alias]['password'])) {
    $passwordHasher = new SimplePasswordHasher();
    $this->data[$this->alias]['password'] = $passwordHasher->hash(
        $this->data[$this->alias]['password']
    );
}

0 个答案:

没有答案