Files
breadcrumb-the-shire/pages/api/v1/me/tokens/revoke-all().php
2026-03-04 15:56:58 +01:00

29 lines
793 B
PHP

<?php
use MintyPHP\Http\ApiAuth;
use MintyPHP\Http\ApiBootstrap;
use MintyPHP\Http\ApiResponse;
ApiBootstrap::init();
ApiResponse::requireMethod('POST');
$apiTokenService = app(\MintyPHP\Service\Auth\ApiTokenService::class);
$apiTokenEndpointService = app(\MintyPHP\Service\Auth\ApiTokenEndpointService::class);
$userId = ApiAuth::userId();
if ($userId <= 0) {
ApiResponse::unauthorized();
}
ApiAuth::requireSelfManageTokens();
$scopedTenantId = ApiAuth::scopedTenantId();
$scopedTenantUuid = $apiTokenEndpointService->resolveTenantUuidById($scopedTenantId);
$result = $apiTokenService->revokeAllForUser($userId, $scopedTenantId);
ApiResponse::success([
'data' => [
'revoked_count' => (int) ($result['count'] ?? 0),
'tenant_uuid' => $scopedTenantUuid,
],
]);