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.