You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.0 KiB

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