[英]How ResetPasswordController works with password_reset table Laravel
The built-in controller for resetting the password Auth \\ Reset Password Controller has the reset function内置密码重置控制器 Auth\\Reset Password Controller 具有重置功能
public function reset(Request $request)
{
$request->validate($this->rules(), $this->validationErrorMessages());
// 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);
}
Well, here we are working with the user and their incoming data.好吧,在这里我们正在处理用户及其传入的数据。 However, I can't understand where the work with the password_resets table (built-in) is going?但是,我无法理解 password_resets 表(内置)的工作进展如何? After all, after password recovery, entries are added/deleted there.毕竟,在恢复密码后,会在那里添加/删除条目。 I think (maybe incorrectly) that this is implemented in the broker () method, but I can't find it in the hierarchy of traits, interfaces, and other classes.我认为(可能是错误的)这是在 broker() 方法中实现的,但是我在特征、接口和其他类的层次结构中找不到它。
Checkout /vendor/laravel/framework/src/Illuminate/Auth/Passwords/DatabaseTokenRepository.php结帐/vendor/laravel/framework/src/Illuminate/Auth/Passwords/DatabaseTokenRepository.php
This is the default class that implements the TokenRepositoryInterface
and is used by the /vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBroker.php
.这是实现TokenRepositoryInterface
的默认类,由/vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBroker.php
。
Inside this class you can find all the actual functionality that handles the password resets including the table operations you mention.在这个类中,您可以找到处理密码重置的所有实际功能,包括您提到的表操作。 For example, one method you'll find is:例如,您会发现一种方法是:
/**
* Create a new token record.
*
* @param \Illuminate\Contracts\Auth\CanResetPassword $user
* @return string
*/
public function create(CanResetPasswordContract $user)
{
$email = $user->getEmailForPasswordReset();
$this->deleteExisting($user);
// We will create a new, random token for the user so that we can e-mail them
// a safe link to the password reset form. Then we will insert a record in
// the database so that we can verify the token within the actual reset.
$token = $this->createNewToken();
$this->getTable()->insert($this->getPayload($email, $token));
return $token;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.