【问题标题】:How to check validation for old password in laravel如何在laravel中检查旧密码的验证
【发布时间】:2019-10-20 06:41:56
【问题描述】:

我想检查用户是否要求输入新密码,然后他必须输入旧密码。但是在我的数据库中,密码保存为哈希密码,我无法验证旧密码和新密码。到目前为止我试过了

'password' => 'nullable|confirmed|min:6',
            'old' => 'required_with:password|same:'.$user->password,

但正如我所说的哈希密码它不起作用。请帮我解决问题。

【问题讨论】:

标签: php laravel validation


【解决方案1】:

还没有尝试过验证。我已经按照以下方式完成了:

use Illuminate\Support\Facades\Hash;

if (!(Hash::check($request->current-password, Auth::user()->password))) {
    return redirect()->back()->with("error","your current password does not match with the password you provided. please try again.");
}

在这种情况下,$request->current-password 是用户提供的旧密码。我正在使用Hash 使用用户密码检查它

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-10-02
    • 2018-06-30
    • 2011-05-23
    • 1970-01-01
    • 1970-01-01
    • 2014-07-27
    • 2018-08-26
    • 1970-01-01
    相关资源
    最近更新 更多