PasswordResetLinkController.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace App\Http\Controllers\Auth;
  3. use App\Http\Controllers\Controller;
  4. use Illuminate\Http\Request;
  5. use Illuminate\Support\Facades\Password;
  6. class PasswordResetLinkController extends Controller
  7. {
  8. /**
  9. * Display the password reset link request view.
  10. *
  11. * @return \Illuminate\View\View
  12. */
  13. public function create()
  14. {
  15. return view('auth.forgot-password');
  16. }
  17. /**
  18. * Handle an incoming password reset link request.
  19. *
  20. * @param \Illuminate\Http\Request $request
  21. * @return \Illuminate\Http\RedirectResponse
  22. *
  23. * @throws \Illuminate\Validation\ValidationException
  24. */
  25. public function store(Request $request)
  26. {
  27. $request->validate([
  28. 'email' => ['required', 'email'],
  29. ]);
  30. // We will send the password reset link to this user. Once we have attempted
  31. // to send the link, we will examine the response then see the message we
  32. // need to show to the user. Finally, we'll send out a proper response.
  33. $status = Password::sendResetLink(
  34. $request->only('email')
  35. );
  36. return $status == Password::RESET_LINK_SENT
  37. ? back()->with('status', __($status))
  38. : back()->withInput($request->only('email'))
  39. ->withErrors(['email' => __($status)]);
  40. }
  41. }