Hash :: make('password')在每次调用时返回不同的结果 [英] Hash::make('password') returning different results at every call

查看:66
本文介绍了Hash :: make('password')在每次调用时返回不同的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,标题基本上描述了我的问题.我的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.

因此,请测试以下代码:

So, test this code:

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!

火箭提示后,我尝试了

    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')在每次调用时返回不同的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆