2017-07-28 135 views
0

我有一个编辑窗体,用户将输入他的新密码,我想检查输入的密码是否与数据库中已存在的密码匹配,如果它匹配,那么它的错误“新密码不能相同旧密码“Laravel更新密码验证

这是我试过的代码,它不适合我! :(

if(\Hash::check($request->password,$old_password)){ 
    return Redirect::back()->withErrors(['message', 'New Password cannot be same as old password']); 
} 
+0

你可以按照这个链接(https://开头计算器。 com/questions/21495502/laravel-hashcheck-allways-return-false) –

+1

[Laravel Hash :: check()allways return false](https://stackoverflow.com/questions/21495502/laravel-hashcheck-allways -return-false) – DMC19

+0

@AddWebSolutionPvtLtd我试过这个解决方案,它不适用于我:( – user3315353

回答

0
if (Hash::check("ValueForEnteredpassword", "HashOldPassword")) { 
     //your code 
    } else { 
    //Your error message 
    } 
0

我想你可以尝试这个例子:

if(!Hash::check($input['current_password'], $user->password)){ 

    dd('Return error with current passowrd is not match.'); 

}else{ 

    dd('Write here your update password code'); 

} 

希望这个例子为您服务!!!