简体   繁体   中英

Why Laravel Auth::check always return false?

I am making an API for an existing database. I noticed the problem first when I saw that Auth::attempt always returned false. Since I have implemented my own SHA1 hashing provider I thought that might be the problem.

But I tried Hash::make('test') and it gave me 'a94a8fe5ccb19ba61c4c0873d391e987982fbbd3'. Then I tried Hash::make($client->pwd) and it gave me the same hash. Correct so far. Finally I did

if (Hash::check('test', $cli->pwd))
{
    [...]
}

and it returned false. From the looks of it the problem isn't my hashing provider and I guess this is also why Auth::attempt is failing. 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. I though the getAuthIdentifier() was the "username" of the table.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM