CakePHP的2.0身份验证登录不工作

编程入门 行业动态 更新时间:2024-10-24 03:21:12
本文介绍了CakePHP的2.0身份验证登录不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我一直争取与此一段时间。我有一个CakePHP的2.0应用程序需要验证,由于事实,即它必须在另一种语言,我踩着从用户名和密码公约AUTOMAGIC用户的路程,并提出我自己的数据库表:

I have been fighting with this for awhile. I have a CakePHP 2.0 application that needs Authentication, due to the fact that it must be in another language, I stepped away from the automagic 'User' with 'Username' and 'Password' convention and made my own database table:

utilizatori('id', 'nume', 'parola')

在我的 AppController的我有以下的定义了,如果我正确理解应该覆盖默认的CakePHP协会,使其使用我的新结构:

In my AppController I have the following defined which if I understood correctly should override the default CakePHP associations and make it use my new structure:

class AppController extends Controller { var $components = array('Session', 'Auth' => array('Form' => array( 'userModel' => 'Utilizator', 'fields' => array('username' => 'nume', 'password' => 'parola'), 'loginAction' => array('controller' => 'utilizatori', 'action' => 'login'), 'loginRedirect' => array('controller' => 'categorii', 'action' => 'admin_index')))); function beforeFilter() { } }

在我的 UtilizatoriController 我有以下登录功能:

In my UtilizatoriController I have the following login function:

function login() { $this->layout = 'admin'; debug($this->data); debug(Security::hash($this->data['Utilizator']['parola'])); debug($this->Auth->login()); /*more here but don't think it's important*/

在数据调试出现与预期值,让我们presume:

The data debug comes up with the expected values, let's presume:

**data['Utilizator']['nume']** = 'Cosmin' **data['Utilizator']['parola']** = 'Cosmin'

在密码哈希调试产生这也是我手动插入到数据库中,但登录功能返回预期的哈希的假

The password hash debug yield the expected hash which I also manually inserted in the database and yet the login function returns false.

我不知道下一步该怎么做任何意见,将AP preciated。此外,有没有进入什么被发送到一个方法的 $这个 - > Auth->登录()

I'm not sure what to do next and any feedback would be appreciated. Also, is there a way to access what gets sent to $this->Auth->login()?

感谢您

推荐答案

事实证明,后面$这个 - > Auth-)失败的原因>登录(是我的 AuthComponent 里面声明的AppController 。经过一番更多的研究和小得惊人,但乐于助人发表于How我可以在CakePHP中2.0.4?我回顾我的code使用不同的模型验证组件,现在它似乎是工作。

As it turns out, the reason behind $this->Auth->login() failing was my declaration of the AuthComponent inside AppController. After some more research and a surprisingly small but helpful post at How can I use different model for Auth component in CakePHP 2.0.4? I reviewed my code and now it seems to be working.

我将在这里发布审查的情况下,没有人会碰到这一点。

I will post the review here in case anyone will bump into this.

public $components = array( 'Session', 'Auth' => array( 'authenticate' => array( 'Form' => array( 'userModel' => 'Utilizator', 'fields' => array( 'username' => 'nume', 'password' => 'parola' ) ) ), 'loginAction' => array('controller' => 'utilizatori', 'action' => 'login'), //Not related to the problem 'loginRedirect' => array('controller' => 'utilizatori', 'action' => 'index'), //Not related to the problem 'logoutRedirect' => array('controller' => 'utilizatori', 'action' => 'index') //Not related to the problem ) );

更多推荐

CakePHP的2.0身份验证登录不工作

本文发布于:2023-11-16 18:30:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1606752.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:身份验证   工作   CakePHP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!