diff --git a/src/Connect.php b/src/Connect.php index 5d225c6..3d815de 100644 --- a/src/Connect.php +++ b/src/Connect.php @@ -192,7 +192,9 @@ class Connect $user = $model::where('email', $model_data['email'])->first() ?? new $model; } - $user->fill($model_data); // TODO + $model_data = $this->convertForeignKeys($model_data); + + $user->fill($model_data); if (in_array($model, $this->synchronized)) $user->{$model::$connectColumnId} = $model_data['id']; @@ -323,16 +325,18 @@ class Connect $model = $this->synchronized[$data['connectResourceType']]; $method = $this->getEventMethod($data['connectEventType']); - if ($data['connectEventType'] != 'deleted') { - try { - $data = $this->get($data['connectResourceType'], $data['connectResourceData']['id']); - } catch (\Exception $e) { + $data = $data['connectResourceData']; + + try { + $data = $this->get($data['connectResourceType'], $data['connectResourceData']['id']); + if ($data['connectEventType'] == 'deleted') { + abort(403, "This resource still exists."); + } + } catch (\Exception $e) { + if ($data['connectEventType'] != 'deleted') { abort(404, "Could not retrieve this resource."); } } - else { - $data = $data['connectResourceData']; - } $data = $this->convertForeignKeys($data);