ConfirmablePasswordController.php 1.0 KB

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