From 1e43e13451b1dcbbe95db597edf504a2951377eb Mon Sep 17 00:00:00 2001 From: IanM Date: Fri, 28 Jun 2024 10:39:58 +0100 Subject: [PATCH] fix: re-introduce /linked-accounts endpoint to avoid breaking change --- extend.php | 1 + src/Api/Controllers/ListProvidersController.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/extend.php b/extend.php index b9fb153..dae9745 100644 --- a/extend.php +++ b/extend.php @@ -44,6 +44,7 @@ (new Extend\Routes('api')) ->get('/users/{id}/linked-accounts', 'users.provider.list', Api\Controllers\ListProvidersController::class) + ->get('/linked-accounts', 'user.provider.list', Api\Controllers\ListProvidersController::class) ->delete('/linked-accounts/{id}', 'users.provider.delete', Api\Controllers\DeleteProviderLinkController::class), (new Extend\ServiceProvider()) diff --git a/src/Api/Controllers/ListProvidersController.php b/src/Api/Controllers/ListProvidersController.php index c5eba01..cd2dbcc 100644 --- a/src/Api/Controllers/ListProvidersController.php +++ b/src/Api/Controllers/ListProvidersController.php @@ -48,7 +48,8 @@ protected function data(ServerRequestInterface $request, Document $document) $actor = RequestUtil::getActor($request); $actor->assertRegistered(); - $user = $this->users->findOrFail(Arr::get($request->getQueryParams(), 'id')); + // If no id is provided, we're looking at the current user. + $user = $this->users->findOrFail(Arr::get($request->getQueryParams(), 'id', $actor->id)); if ($actor->id !== $user->id) { $actor->assertCan('moderateUserProviders');