【问题标题】:Laravel get plain text password when user enters the password reset form当用户输入密码重置表单时,Laravel 获取纯文本密码
【发布时间】:2020-01-27 09:00:22
【问题描述】:

在 laravel 中进行密码重置时,我还需要获取用户在密码中输入的密码并确认密码字段,我需要这个,因为我必须将其发布到另一个 api 以在那里更新密码.

您能告诉我如何访问它吗?

我已经检查了控制器的 Auth ResetPasswordcontroller.php,但我不知道如何拦截和获取纯文本密码,但仍然无法正常重置密码。

【问题讨论】:

    标签: php laravel


    【解决方案1】:

    您可以简单地从控制器中的 ResetsPasswords 特征覆盖 reset() 方法。

    ResetPasswordController.php

    class ResetPasswordController extends Controller
    {
        use ResetsPasswords;
    
        // ...
    
        public function reset(Request $request)
        {
            // the code in this section is copied from ResetsPasswords@reset
            $request->validate($this->rules(), $this->validationErrorMessages());
    
            // --- put your custom code here ------------
    
            $plaintext_password = $request->password;
    
    
    
            // --- end custom code ----------------------
    
            // Here we will attempt to reset the user's password. If it is successful we
            // will update the password on an actual user model and persist it to the
            // database. Otherwise we will parse the error and return the response.
            $response = $this->broker()->reset(
                $this->credentials($request), function ($user, $password) {
                    $this->resetPassword($user, $password);
                }
            );
    
            // If the password was successfully reset, we will redirect the user back to
            // the application's home authenticated view. If there is an error we can
            // redirect them back to where they came from with their error message.
            return $response == Password::PASSWORD_RESET
                        ? $this->sendResetResponse($request, $response)
                        : $this->sendResetFailedResponse($request, $response);
        }    
    }
    

    【讨论】:

    • 谢谢,这正是我要找的。​​span>
    猜你喜欢
    • 2023-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-26
    • 2016-05-21
    • 1970-01-01
    • 2016-09-14
    • 1970-01-01
    相关资源
    最近更新 更多