[英]Why Laravel Auth::check always return false?
I am making an API for an existing database. 我正在为现有数据库创建API。 I noticed the problem first when I saw that Auth::attempt always returned false.
当我看到Auth :: attempt总是返回false时,我首先注意到了这个问题。 Since I have implemented my own SHA1 hashing provider I thought that might be the problem.
由于我已经实现了自己的SHA1哈希提供程序,因此我认为这可能是问题所在。
But I tried Hash::make('test') and it gave me 'a94a8fe5ccb19ba61c4c0873d391e987982fbbd3'. 但是我尝试了Hash :: make('test'),它给了我'a94a8fe5ccb19ba61c4c0873d391e987982fbbd3'。 Then I tried Hash::make($client->pwd) and it gave me the same hash.
然后我尝试了Hash :: make($ client-> pwd),它给了我同样的哈希值。 Correct so far.
到目前为止正确。 Finally I did
最后我做了
if (Hash::check('test', $cli->pwd))
{
[...]
}
and it returned false. 它返回false。 From the looks of it the problem isn't my hashing provider and I guess this is also why Auth::attempt is failing.
从外观上看,问题不在于我的哈希提供程序,我猜这也是Auth :: attempt失败的原因。 Can anyone tell me why ?
谁能告诉我为什么?
The problem was on my end. 问题出在我身上。 I misunderstood the concept of Eloquent.
我误解了口才的概念。 I had to change in my UserInterface class, the one my user model mapped to, getAuthIdentifier() to return "id" which is the PrimaryKey of my table.
我必须在UserInterface类中进行更改,该类是我的用户模型映射到的类,即getAuthIdentifier()返回“ id”,即表的PrimaryKey。 I though the getAuthIdentifier() was the "username" of the table.
我虽然getAuthIdentifier()是表的“用户名”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.