File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,9 @@ public function handle(SecureFieldsUpdated $event): void
15
15
{
16
16
$ notificationClass = config ('security-notifications.notifications.secure_fields ' );
17
17
18
- Notification::route ('mail ' , $ event ->original_email )
19
- ->notify (new $ notificationClass ($ event ->fields , $ event ->updated_at ));
18
+ if (! empty ($ event ->original_email )) {
19
+ Notification::route ('mail ' , $ event ->original_email )
20
+ ->notify (new $ notificationClass ($ event ->fields , $ event ->updated_at ));
21
+ }
20
22
}
21
23
}
Original file line number Diff line number Diff line change 30
30
&& Arr::has ($ notification ->fields , 'username ' )
31
31
&& Arr::has ($ notification ->fields , 'password ' );
32
32
});
33
+ });
34
+
35
+ it ('does not send the notification if the email is an empty string ' , function () {
36
+ Notification::fake ();
37
+
38
+ $ user = User::factory ()->create ();
39
+
40
+ $ event = (new SecureFieldsUpdated (
41
+ model: $ user ,
42
+ fields: [],
43
+ original_email: '' ,
44
+ updated_at: now (),
45
+ ));
46
+
47
+ (new SendSecurityNotification )->handle ($ event );
48
+
49
+ Notification::assertNothingSent ();
33
50
});
You can’t perform that action at this time.
0 commit comments