ConfirmablePasswordController.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 Inertia\Inertia;
  9. use Inertia\Response;
  10. class ConfirmablePasswordController extends Controller
  11. {
  12. /**
  13. * Show the confirm password page.
  14. */
  15. public function show(): Response
  16. {
  17. return Inertia::render('auth/ConfirmPasswordPage');
  18. }
  19. /**
  20. * Confirm the user's password.
  21. */
  22. public function store(Request $request): RedirectResponse
  23. {
  24. if (
  25. !Auth::guard('web')->validate([
  26. 'email' => $request->user()->email,
  27. 'password' => $request->password,
  28. ])
  29. ) {
  30. throw ValidationException::withMessages([
  31. 'password' => __('auth.password'),
  32. ]);
  33. }
  34. $request->session()->put('auth.password_confirmed_at', time());
  35. return redirect()->intended(route('dashboard', absolute: false));
  36. }
  37. }