confirm-password.blade.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. use Illuminate\Support\Facades\Auth;
  3. use Illuminate\Validation\ValidationException;
  4. use Livewire\Attributes\Layout;
  5. use Livewire\Volt\Component;
  6. new #[Layout('layouts.guest')] class extends Component
  7. {
  8. public string $password = '';
  9. /**
  10. * Confirm the current user's password.
  11. */
  12. public function confirmPassword(): void
  13. {
  14. $this->validate([
  15. 'password' => ['required', 'string'],
  16. ]);
  17. if (! Auth::guard('web')->validate([
  18. 'email' => Auth::user()->email,
  19. 'password' => $this->password,
  20. ])) {
  21. throw ValidationException::withMessages([
  22. 'password' => __('auth.password'),
  23. ]);
  24. }
  25. session(['auth.password_confirmed_at' => time()]);
  26. $this->redirectIntended(default: route('dashboard', absolute: false), navigate: true);
  27. }
  28. }; ?>
  29. <div>
  30. <div class="mb-4 text-sm text-gray-600 dark:text-gray-400">
  31. {{ __('This is a secure area of the application. Please confirm your password before continuing.') }}
  32. </div>
  33. <form wire:submit="confirmPassword">
  34. <!-- Password -->
  35. <div>
  36. <x-input-label for="password" :value="__('Password')" />
  37. <x-text-input wire:model="password"
  38. id="password"
  39. class="block mt-1 w-full"
  40. type="password"
  41. name="password"
  42. required autocomplete="current-password" />
  43. <x-input-error :messages="$errors->get('password')" class="mt-2" />
  44. </div>
  45. <div class="flex justify-end mt-4">
  46. <x-primary-button>
  47. {{ __('Confirm') }}
  48. </x-primary-button>
  49. </div>
  50. </form>
  51. </div>