Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix: check token.scope for access resource display (#46603)

Hieuc713508fce06
diff --git a/apps/studio/components/interfaces/Account/AccessTokens/Scoped/ViewTokenSheet.tsx b/apps/studio/components/interfaces/Account/AccessTokens/Scoped/ViewTokenSheet.tsx
index 8ca78ea879c..e3a6a51075c 100644
--- a/apps/studio/components/interfaces/Account/AccessTokens/Scoped/ViewTokenSheet.tsx
+++ b/apps/studio/components/interfaces/Account/AccessTokens/Scoped/ViewTokenSheet.tsx
@@ -231,11 +231,16 @@ export function ViewTokenSheet({ visible, tokenId, onClose }: ViewTokenSheetProp
<TableRow>
<TableCell colSpan={2}>
<p className="text-foreground-light text-center py-4">
- {(token?.organization_slugs &&
- token.organization_slugs.length > 0) ||
- (token?.project_refs && token.project_refs.length > 0)
- ? 'This token has access to specific organizations and projects.'
- : 'This token has access to all resources.'}
+ {token?.scope === 'organization'
+ ? token.organization_slugs &&
+ token.organization_slugs.length > 0
+ ? 'This token has access to specific organizations.'
+ : 'This token has no accessible organizations.'
+ : token?.scope === 'project'
+ ? token.project_refs && token.project_refs.length > 0
+ ? 'This token has access to specific projects.'
+ : 'This token has no accessible projects.'
+ : 'This token has access to all resources.'}
</p>
</TableCell>
</TableRow>
diff --git a/packages/api-types/types/platform.d.ts b/packages/api-types/types/platform.d.ts
index 08ebaa05eb8..ba5359d3206 100644
--- a/packages/api-types/types/platform.d.ts
+++ b/packages/api-types/types/platform.d.ts
@@ -7031,6 +7031,8 @@ export interface components {
organization_slugs?: string[]
permissions: string[]
project_refs?: string[]
+ /** @enum {string} */
+ scope: 'user' | 'organization' | 'project'
token_alias: string
}
GetScopedAccessTokensResponse: {