File tree Expand file tree Collapse file tree 5 files changed +57
-28
lines changed Expand file tree Collapse file tree 5 files changed +57
-28
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace App \Livewire \Actions ;
6
+
7
+ use Illuminate \Support \Facades \Auth ;
8
+ use Illuminate \Support \Facades \Session ;
9
+
10
+ final class Logout
11
+ {
12
+ public function __invoke (): void
13
+ {
14
+ Auth::guard ('web ' )->logout ();
15
+
16
+ Session::invalidate ();
17
+ Session::regenerateToken ();
18
+ }
19
+ }
Original file line number Diff line number Diff line change 177
177
App \Providers \AuthServiceProvider::class,
178
178
// App\Providers\BroadcastServiceProvider::class,
179
179
App \Providers \EventServiceProvider::class,
180
+ App \Providers \VoltServiceProvider::class,
180
181
App \Providers \RouteServiceProvider::class,
181
182
182
183
],
Original file line number Diff line number Diff line change @@ -205,22 +205,8 @@ class="size-5 text-gray-400 dark:gray-500 group-hover:text-gray-500 dark:group-h
205
205
/>
206
206
{{ __ (' global.navigation.settings' ) } }
207
207
</x-link >
208
- <form method =" POST" action =" {{ route (' logout' ) } }" >
209
- @csrf
210
- <button
211
- type =" submit"
212
- class =" group flex w-full items-center gap-2 py-1.5 text-sm text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-white"
213
- tabindex =" -1"
214
- id =" logout"
215
- >
216
- <x-icon .logout
217
- class =" size-5 text-gray-400 dark:gray-500 group-hover:text-gray-500 dark:group-hover:text-gray-300"
218
- stroke-width =" 1.5"
219
- aria-hidden =" true"
220
- />
221
- {{ __ (' global.logout' ) } }
222
- </button >
223
- </form >
208
+
209
+ <livewire:components .logout />
224
210
</div >
225
211
</div >
226
212
</div >
Original file line number Diff line number Diff line change @@ -116,18 +116,7 @@ class="size-8"
116
116
:href =" route('user.settings')"
117
117
:title =" __('Paramètres')"
118
118
/>
119
- <form method =" POST" action =" {{ route (' logout' ) } }" >
120
- @csrf
121
- <button
122
- type =" submit"
123
- class =" group flex w-full items-center text-sm font-medium text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-white"
124
- role =" menuitem"
125
- tabindex =" -1"
126
- id =" logout-mobile"
127
- >
128
- {{ __ (' global.logout' ) } }
129
- </button >
130
- </form >
119
+ <livewire:components .logout />
131
120
</div >
132
121
@else
133
122
<div class =" flex flex-col space-y-4" >
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types = 1 );
4
+
5
+ use App\Livewire\Actions\ Logout ;
6
+ use Livewire\Volt\ Component ;
7
+
8
+ new class extends Component
9
+ {
10
+ /**
11
+ * Log the current user out of the application.
12
+ */
13
+ public function logout (Logout $logout ): void
14
+ {
15
+ $logout ();
16
+
17
+ $this -> redirect (' /' , navigate : true );
18
+ }
19
+ }; ? >
20
+
21
+ <div >
22
+ <button
23
+ wire:click =" logout"
24
+ class =" group flex w-full items-center gap-2 text-sm font-medium text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-white"
25
+ tabindex =" -1"
26
+ >
27
+ <x-icon .logout
28
+ class =" hidden size-5 text-gray-400 dark:gray-500 group-hover:text-gray-500 dark:group-hover:text-gray-300 lg:block"
29
+ stroke-width =" 1.5"
30
+ aria-hidden =" true"
31
+ />
32
+ {{ __ (' global.logout' ) } }
33
+ </button >
34
+ </div >
You can’t perform that action at this time.
0 commit comments