【问题标题】:Laravel Update password validationLaravel 更新密码验证
【发布时间】:2018-01-04 12:27:09
【问题描述】:

我有一个编辑表单,用户将在其中输入他的新密码,我想检查输入的密码是否与数据库中已经存在的密码匹配,如果匹配则错误“新密码不能与旧密码相同”

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

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

【问题讨论】:

  • 您可以点击此链接 (stackoverflow.com/questions/21495502/…)
  • @AddWebSolutionPvtLtd 我尝试了该解决方案,但它对我不起作用:(
  • @user3315353 请检查我的回答希望这对你有用
  • 您是否检查过您在$request->password$old_password 中确实获得了您期望的值?否则,与documentation 进行比较时,您的代码乍一看似乎是正确的。在不工作方面,它是如何不工作的?是不是重定向,是不是报错了?它什么都不做吗?等

标签: php jquery laravel laravel-5.2


【解决方案1】:
if (Hash::check("ValueForEnteredpassword", "HashOldPassword")) { 
      //your code  
    }   else { 
    //Your error message 
    }

【讨论】:

    【解决方案2】:

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

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

    希望这个例子适合你!!!

    【讨论】:

      猜你喜欢
      • 2015-04-08
      • 2018-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-31
      • 2017-07-26
      • 2011-11-29
      • 2015-10-10
      相关资源
      最近更新 更多