Skip to content

Commit

Permalink
Merge pull request #12 from FoskyM/bugfix/10-two-records
Browse files Browse the repository at this point in the history
fix: two records saved while adding a new client
  • Loading branch information
FoskyM committed Apr 10, 2024
2 parents 7880f06 + df9b85a commit 39d08e3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Api/Controller/CreateClientController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ protected function data(ServerRequestInterface $request, Document $document)

$attributes = Arr::get($request->getParsedBody(), 'data.attributes');

if ($client = Client::where('client_id', Arr::get($attributes, 'client_id'))->first()) {
return $client;
}

return Client::create([
'client_id' => Arr::get($attributes, 'client_id'),
'client_secret' => Arr::get($attributes, 'client_secret'),
Expand Down

0 comments on commit 39d08e3

Please sign in to comment.