@william_stoltenberg
Для отправки письма с новым паролем в Laravel необходимо выполнить следующие шаги:
1
|
Route::get('password/reset/{token}', 'AuthForgotPasswordController@showResetForm')->name('password.reset'); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
public function reset(Request $request) { $this->validate($request, [ 'token' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed|min:8', ]); $credentials = $request->only( 'email', 'password', 'password_confirmation', 'token' ); $response = $this->broker()->reset( $credentials, function ($user, $password) { $this->resetPassword($user, $password); } ); if ($response == Password::PASSWORD_RESET) { return redirect()->route('login')->with('status', trans($response)); } return back() ->withInput($request->only('email')) ->withErrors(['email' => trans($response)]); } |
1 2 3 4 5 6 7 8 9 10 11 12 |
public function sendResetLinkEmail(Request $request) { $this->validateEmail($request); $response = $this->broker()->sendResetLink( $request->only('email') ); return $response == Password::RESET_LINK_SENT ? back()->with('status', trans($response)) : back()->withErrors(['email' => trans($response)]); } |
1 2 3 4 5 6 |
'passwords' => [ 'provider' => 'users', 'email' => 'auth.emails.password', 'table' => 'password_resets', 'expire' => 60, ], |
Теперь при запросе на страницу сброса пароля, пользователь получит пись