Log an explicit error when trying to create a Customer without a Mailbox
This commit is contained in:
parent
4207b8093c
commit
f861f240d1
1 changed files with 16 additions and 5 deletions
|
@ -6,10 +6,14 @@
|
|||
|
||||
namespace Modules\MMFRestrictedCustomers\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Database\Eloquent\Factory;
|
||||
use Eventy;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factory;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
use App\User;
|
||||
|
||||
use Modules\MMFRestrictedCustomers\Console\Commands\FetchEmails;
|
||||
|
||||
class MMFRestrictedCustomersServiceProvider extends ServiceProvider {
|
||||
|
@ -57,13 +61,20 @@ class MMFRestrictedCustomersServiceProvider extends ServiceProvider {
|
|||
Eventy::addAction(
|
||||
'customer.set_data',
|
||||
function($customer, $data, $replace_data) {
|
||||
if ( isset($data['mailbox']) ) {
|
||||
if ( array_key_exists('mailbox', $data) ) {
|
||||
// TODO: Check that the current user is allowed to access this Mailbox.
|
||||
$data['mailbox_id'] = $data['mailbox'];
|
||||
unset($data['mailbox']);
|
||||
}
|
||||
// TODO: Throw an error if the Mailbox is not set.
|
||||
$customer->mailbox_id = $data['mailbox_id'];
|
||||
if ( array_key_exists('mailbox_id', $data) ) {
|
||||
$customer->mailbox_id = $data['mailbox_id'];
|
||||
} else {
|
||||
if ( $customer->mailbox_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.');
|
||||
}
|
||||
}
|
||||
},
|
||||
$priority = 20,
|
||||
$arguments = 3
|
||||
|
|
Loading…
Reference in a new issue