progetto di test della creazione di un progetto basato sul framework laravel e aggiunta form login e register utilizzando breeze
filippo.bertilotti
2024-04-17 637d67e9cd8572ca9f637a0293b06b16d6f287c6
commit | author | age
f7d0ce 1 <?php
F 2
3 use App\Providers\RouteServiceProvider;
4 use Illuminate\Support\Facades\Auth;
5 use Illuminate\Validation\ValidationException;
6 use Livewire\Attributes\Layout;
7 use Livewire\Volt\Component;
8
9 new #[Layout('layouts.guest')] class extends Component
10 {
11     public string $password = '';
12
13     /**
14      * Confirm the current user's password.
15      */
16     public function confirmPassword(): void
17     {
18         $this->validate([
19             'password' => ['required', 'string'],
20         ]);
21
22         if (! Auth::guard('web')->validate([
23             'email' => Auth::user()->email,
24             'password' => $this->password,
25         ])) {
26             throw ValidationException::withMessages([
27                 'password' => __('auth.password'),
28             ]);
29         }
30
31         session(['auth.password_confirmed_at' => time()]);
32
33         $this->redirectIntended(default: RouteServiceProvider::HOME, navigate: true);
34     }
35 }; ?>
36
37 <div>
38     <div class="mb-4 text-sm text-gray-600">
39         {{ __('This is a secure area of the application. Please confirm your password before continuing.') }}
40     </div>
41
42     <form wire:submit="confirmPassword">
43         <!-- Password -->
44         <div>
45             <x-input-label for="password" :value="__('Password')" />
46
47             <x-text-input wire:model="password"
48                           id="password"
49                           class="block mt-1 w-full"
50                           type="password"
51                           name="password"
52                           required autocomplete="current-password" />
53
54             <x-input-error :messages="$errors->get('password')" class="mt-2" />
55         </div>
56
57         <div class="flex justify-end mt-4">
58             <x-primary-button>
59                 {{ __('Confirm') }}
60             </x-primary-button>
61         </div>
62     </form>
63 </div>