File tree 2 files changed +13
-0
lines changed
2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,10 @@ protected function listenForEvents(): void
119
119
$ this ->app ->booted (function () {
120
120
$ this ->callAfterResolving (Dispatcher::class, function (Dispatcher $ event , Application $ app ) {
121
121
$ event ->listen (function (Logout $ event ) use ($ app ) {
122
+ if ($ event ->user === null ) {
123
+ return ;
124
+ }
125
+
122
126
$ pulse = $ app ->make (Pulse::class);
123
127
124
128
$ pulse ->rescue (fn () => $ pulse ->rememberUser ($ event ->user ));
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
+ use Illuminate \Auth \Events \Logout ;
3
4
use Illuminate \Contracts \Auth \Authenticatable ;
4
5
use Illuminate \Support \Collection ;
5
6
use Illuminate \Support \Facades \App ;
6
7
use Illuminate \Support \Facades \Auth ;
7
8
use Illuminate \Support \Facades \Config ;
9
+ use Illuminate \Support \Facades \Event ;
8
10
use Illuminate \Support \Facades \Facade ;
9
11
use Laravel \Pulse \Contracts \ResolvesUsers ;
10
12
use Laravel \Pulse \Contracts \Storage ;
@@ -246,6 +248,13 @@ public function find(int|string|null $key): object
246
248
expect ($ persistentMiddleware )->not ->toContain (MyTestMiddleware::class.':admin ' );
247
249
});
248
250
251
+ it ('handles logout events when there is no user ' , function () {
252
+ // This will throw a type error when unhandled...
253
+ Event::dispatch (new Logout ('session ' , user: null ));
254
+
255
+ expect (true )->toBe (true );
256
+ });
257
+
249
258
class MyTestMiddleware
250
259
{
251
260
//
You can’t perform that action at this time.
0 commit comments