Laravel Hash :: check()总是返回false [英] Laravel Hash::check() always return false

查看:69
本文介绍了Laravel Hash :: check()总是返回false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有个人资料表格,用户可以编辑自己的个人资料.以这种形式,我有当前密码.必须匹配才能保存到数据库中.

I have profile form for user can edit own profiles. in this form I have current password. that must be match from seved into database.

表格:

{{ Form::password('currPassword', array('id'=>'currPassword')) }}

我想在Controller中具有此功能以通过数据库进行检查.

i want to have this function in Controller to check this with database.

$data = User::find($id);
if( ! Hash::check( $data->password , Input::get('currPassword') ) )
{
    return Redirect::to('/admin/profile')
        ->with('message', 'Current Password Error !')
        ->withInput();
}

123456密码输入数据库是可以的,将123456放入currPassword后必须返回TRUE,但始终返回FALSE.

hashed 123456 password into database is ok and after putting 123456 in currPassword that must be return TRUE but that return FALSE always.

推荐答案

您使用了错误的参数顺序.是Hash::check($input, $hash),而不是相反.

You're using the wrong argument order. It's Hash::check($input, $hash), not the other way around.

简短修补程序示例:

[1] > $pw = 123456;
// 123456
[2] > $hashed = Hash::make($pw);
// '$2y$10$xSugoyKv765TY8DsERJ2/.mPIOwLNdM5Iw1n3x1XNVymBlHNG4cX6'
[3] > Hash::check($hashed, $pw);
// false
[4] > Hash::check($pw, $hashed);
// true

这篇关于Laravel Hash :: check()总是返回false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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