Fixed api token endpoint documentation

This commit is contained in:
Constantin Graf
2025-02-11 14:44:59 -05:00
committed by Constantin Graf
parent 4ea55e5867
commit 69a8c8bb2b
6 changed files with 38 additions and 13 deletions

View File

@@ -59,11 +59,13 @@ class ApiTokenController extends Controller
*
* @throws AuthorizationException
*/
public function revoke(string $apiTokenId): JsonResponse
public function revoke(Token $apiToken): JsonResponse
{
$user = $this->user();
$apiToken = $user->tokens()->where('id', $apiTokenId)->firstOrFail();
if ($apiToken->user_id !== $user->getKey()) {
throw new AuthorizationException('API token does not belong to user');
}
$apiToken->revoke();
@@ -77,11 +79,13 @@ class ApiTokenController extends Controller
*
* @throws AuthorizationException
*/
public function destroy(string $apiTokenId): JsonResponse
public function destroy(Token $apiToken): JsonResponse
{
$user = $this->user();
$apiToken = $user->tokens()->where('id', $apiTokenId)->firstOrFail();
if ($apiToken->user_id !== $user->getKey()) {
throw new AuthorizationException('API token does not belong to user');
}
$apiToken->delete();