Laravel:重置密码未经验证获取6位数字

Laravel:重置密码未经验证获取6位数字,laravel,laravel-5.5,Laravel,Laravel 5.5,我有一个简单的功能来重置我的密码。在我的函数中,密码值的最低要求是1位数,但当我尝试更新密码时,它不会更新,当我在密码中输入6位数时,它工作正常 我发现在vendor\laravel\framework\src\illumb\Auth\Passwords中,passwordBroker.phpfile有一个函数 protected function validatePasswordWithDefaults(array $credentials) { list($password, $c

我有一个简单的功能来重置我的密码。在我的函数中,密码值的最低要求是1位数,但当我尝试更新密码时,它不会更新,当我在密码中输入6位数时,它工作正常

我发现在vendor\laravel\framework\src\illumb\Auth\Passwords中,passwordBroker.phpfile有一个函数

 protected function validatePasswordWithDefaults(array $credentials)
{
    list($password, $confirm) = [
        $credentials['password'],
        $credentials['password_confirmation'],
    ];

    return $password === $confirm && mb_strlen($password) >= 6; // here it is
}
它包含$password>=6如何删除它的验证,当我更改此文件时,它正在工作。在my.gitignore供应商文件夹上,未在live中更新。解决办法是什么?如何覆盖此验证

这里是我的重置密码功能,仅供参考


以下是解决此问题的方法:

public function resetPassword(ResetPasswordRequest $request, JWTAuth $JWTAuth)
{
    ... // Validator check and json response

    $broker = $this->broker();

    // Replace default validation of the PasswordBroker
    $broker->validator(function (array $credentials) {
        return true; // Password match is already validated in PasswordBroker so just return true here
    });

    $response = $broker->reset(
        $this->credentials($request), function ($user, $password) {
        $this->reset($user, $password);
    });

    ...
}

首先生成代理的一个实例,然后添加一个可调用函数,该函数将用于验证,而不是validatePasswordWithDefaults。在这里,您只需要返回true,因为PasswordBroker已经有一个检查$password===$confirm。

这就是您可以修复此问题的方法:

public function resetPassword(ResetPasswordRequest $request, JWTAuth $JWTAuth)
{
    ... // Validator check and json response

    $broker = $this->broker();

    // Replace default validation of the PasswordBroker
    $broker->validator(function (array $credentials) {
        return true; // Password match is already validated in PasswordBroker so just return true here
    });

    $response = $broker->reset(
        $this->credentials($request), function ($user, $password) {
        $this->reset($user, $password);
    });

    ...
}
首先生成代理的一个实例,然后添加一个可调用函数,该函数将用于验证,而不是validatePasswordWithDefaults。在这里,您只需要返回true,因为PasswordBroker已经有一个检查$password===$confirm