Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oauth bug fixes. #1657

Merged
merged 1 commit into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/Http/Controllers/OAuth2Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Models\Person;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Auth;
use InvalidArgumentException;

class OAuth2Controller extends ApiController
{
Expand Down
41 changes: 21 additions & 20 deletions app/Http/Controllers/OauthClientController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,62 +32,63 @@ public function index(): JsonResponse
public function store(): JsonResponse
{
$this->authorize('store', OauthClient::class);
$client = new OauthClient;
$this->fromRest($client);
$oauthClient = new OauthClient;
$this->fromRest($oauthClient);

if ($client->save()) {
return $this->success($client);
if ($oauthClient->save()) {
return $this->success($oauthClient);
}

return $this->restError($client);
return $this->restError($oauthClient);
}

/**
* Display the specified OAuth Client.
*
* @param OauthClient $client
* @param OauthClient $oauthClient
* @return JsonResponse
* @throws AuthorizationException
*/

public function show(OauthClient $client): JsonResponse
public function show(OauthClient $oauthClient): JsonResponse
{
$this->authorize('show', $client);
return $this->success($client);
$this->authorize('show', $oauthClient);
return $this->success($oauthClient);
}

/**
* Update the specified OAuth Client in storage.
*
* @param OauthClient $client
* @param OauthClient $oauthClient
* @return JsonResponse
* @throws AuthorizationException|ValidationException
*/

public function update(OauthClient $client): JsonResponse
public function update(OauthClient $oauthClient): JsonResponse
{
$this->authorize('update', $client);
$this->fromRest($client);
error_log('** MODEL '.json_encode($oauthClient));
$this->authorize('update', $oauthClient);
$this->fromRest($oauthClient);

if ($client->save()) {
return $this->success($client);
if ($oauthClient->save()) {
return $this->success($oauthClient);
}

return $this->restError($client);
return $this->restError($oauthClient);
}

/**
* Delete an OAuth Client record
*
* @param OauthClient $client
* @param OauthClient $oauthClient
* @return JsonResponse
* @throws AuthorizationException
*/

public function destroy(OauthClient $client): JsonResponse
public function destroy(OauthClient $oauthClient): JsonResponse
{
$this->authorize('destroy', $client);
$client->delete();
$this->authorize('destroy', $oauthClient);
$oauthClient->delete();
return $this->restDeleteSuccess();
}
}