ConfirmablePasswordController.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace App\Http\Controllers\Auth;
  3. use App\Http\Controllers\Controller;
  4. use App\Providers\RouteServiceProvider;
  5. use Illuminate\Http\Request;
  6. use Illuminate\Support\Facades\Auth;
  7. use Illuminate\Validation\ValidationException;
  8. class ConfirmablePasswordController extends Controller
  9. {
  10. /**
  11. * Show the confirm password view.
  12. *
  13. * @return \Illuminate\View\View
  14. */
  15. public function show()
  16. {
  17. return view('auth.confirm-password');
  18. }
  19. /**
  20. * Confirm the user's password.
  21. *
  22. * @param \Illuminate\Http\Request $request
  23. * @return mixed
  24. */
  25. public function store(Request $request)
  26. {
  27. if (! Auth::guard('web')->validate([
  28. 'email' => $request->user()->email,
  29. 'password' => $request->password,
  30. ])) {
  31. throw ValidationException::withMessages([
  32. 'password' => __('auth.password'),
  33. ]);
  34. }
  35. $request->session()->put('auth.password_confirmed_at', time());
  36. return redirect()->intended(RouteServiceProvider::HOME);
  37. }
  38. }