Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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:

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

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();
}

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
423 views
Welcome To Ask or Share your Answers For Others

1 Answer

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

Short tinker example:

[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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...