問題描述
所以,標題基本上描述了我的問題.我的 Hash:make() 瘋了.我創建了一個帶有散列密碼的用戶表,但我無法讓 Laravel 接受我的憑據,我認為問題出在 Hash::make 中.
So,the title basically describes my problem. My Hash:make() is gone crazy. I've created a users table with a hashed password, but I can't get Laravel to accept my credentials and I think the problem is in the Hash::make.
所以,測試這段代碼:
Route::get('/', function()
{
return Hash::make('1234');
});
每次我點擊路由/"時,它都會給我一個不同的哈希值.
every time I hit route '/' it gives me a different hash.
每個人都這樣嗎?有什么建議?我迷路了!
Does it behave like that for everyone? Any suggestions? I'm lost!
Rocket tip 之后,我試過了
After Rocket tip, I've tried
if(!Hash::check('1234', User::find(1)->password))
return 'not';
$credentials = array(
'email' => 'email@example.com',
'password' => '1234',
//'remember' => $remember
);
if(Auth::attempt($credentials))
{
return View::make('hello');
}
return "Invalid Credentials";
但它不斷返回無效憑據".我已經仔細檢查了我的 auth.php 并且它設置正確.還有什么我可以嘗試的嗎?
But it keeps returning "Invalid Credentials". I've double checked my auth.php and it's setup correctly. Anything else I could try?
推薦答案
這就是它應該做的.它應該每次創建不同的密碼,因為它正在創建一個新的隨機鹽.
That's what it's supposed to do. It's supposed to create a different password each time, as it's creating a new random salt.
要檢查用戶的密碼,請使用 check
方法.
To check the user's password, you use the check
method.
if(Hash::check('1234', $password)){
}
或者你可以使用Auth::attempt
.
$user = array(
'email' => $email,
'password' => $password
);
if (Auth::attempt($user)){
}
文檔:http://laravel.com/docs/security
這篇關于Hash::make('password') 在每次調用時返回不同的結果的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!