From 732695922a99518075d6c50d53194d6e38bc934e Mon Sep 17 00:00:00 2001 From: Antoine Le Gonidec Date: Mon, 22 Jul 2024 18:35:47 +0200 Subject: [PATCH] Fix the error shown when trying to create a Customer with no linked Mailbox --- Providers/MMFRestrictedCustomersServiceProvider.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Providers/MMFRestrictedCustomersServiceProvider.php b/Providers/MMFRestrictedCustomersServiceProvider.php index 93bf992..4871235 100644 --- a/Providers/MMFRestrictedCustomersServiceProvider.php +++ b/Providers/MMFRestrictedCustomersServiceProvider.php @@ -70,7 +70,13 @@ class MMFRestrictedCustomersServiceProvider extends ServiceProvider { if ( array_key_exists('mailbox_id', $data) ) { $customer->mailbox_id = $data['mailbox_id']; } else { - $customer = Customer::find($customer->id); + $customer_id = $customer->id; + if ( $customer_id == null ) { + Log::error('The creation of a Customer with no link to a Mailbox is not allowed, and has been aborted.'); + // TODO: Error out more gracefully. + abort(500, 'The creation of a Customer with no link to a Mailbox is not allowed, and has been aborted.'); + } + $customer = Customer::find($customer_id); if ( $customer == null ) { Log::error('Trying to use a Customer in another Mailbox than the one it is linked to is not allowed, and has been aborted.'); // TODO: Error out more gracefully.