当用户输入密码重置表单时,Laravel将获得纯文本密码



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

你能告诉我如何访问这个.

我已经签入了控制器的身份验证重置密码控制器.php但我无法弄清楚如何拦截和获取纯文本密码,但仍然会进行正常的密码重置。

您只需从控制器中的ResetPasswords特征中覆盖reset()方法即可。

重置密码控制器.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);
}    
}

最新更新