The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Update permission checking for creating a project
Joshen Lim52947392caa7
diff --git a/studio/components/interfaces/Organization/NewProject/NotOrganizationOwnerWarning.tsx b/studio/components/interfaces/Organization/NewProject/NotOrganizationOwnerWarning.tsxindex 5a442046f33..dfe6a9013b5 100644--- a/studio/components/interfaces/Organization/NewProject/NotOrganizationOwnerWarning.tsx+++ b/studio/components/interfaces/Organization/NewProject/NotOrganizationOwnerWarning.tsx@@ -8,12 +8,11 @@ const NotOrganizationOwnerWarning = () => {icon={<IconAlertCircle className="text-white" size="large" strokeWidth={1.5} />}defaultVisibility={true}hideCollapse- title="You do not have permission to create a project"+ title="You do not have permissions to create a project"description={<div className="space-y-3"><p className="text-sm leading-normal">- Only the organization owner can create new projects. Contact your organization owner- to create a new project for this organization.+ Contact your organization owner or adminstrator to create a new project.</p></div>}diff --git a/studio/components/interfaces/Organization/TeamSettings/MembersView.tsx b/studio/components/interfaces/Organization/TeamSettings/MembersView.tsxindex ce984977b71..9377bf67ba8 100644--- a/studio/components/interfaces/Organization/TeamSettings/MembersView.tsx+++ b/studio/components/interfaces/Organization/TeamSettings/MembersView.tsx@@ -85,7 +85,11 @@ const MembersView = () => {const role = (roles || []).find((role) => role.id === memberRoleId)const memberIsUser = x.primary_email == PageState.user.primary_email- console.log(x.gotrue_id, x.primary_email, x.role_ids)+ console.log({+ id: x.gotrue_id,+ email: x.primary_email,+ roleIds: x.role_ids,+ })return (<>diff --git a/studio/pages/new/[slug].tsx b/studio/pages/new/[slug].tsxindex e81e8d879c0..e7223e9aa7c 100644--- a/studio/pages/new/[slug].tsx+++ b/studio/pages/new/[slug].tsx@@ -1,7 +1,3 @@-/**- * Org is selected, creating a new project- */-import Router, { useRouter } from 'next/router'import { useRef, useState, useEffect } from 'react'import { debounce, isUndefined, values } from 'lodash'@@ -9,6 +5,7 @@ import { toJS } from 'mobx'import { observer } from 'mobx-react-lite'import generator from 'generate-password'import { Button, Listbox, IconUsers, Input, IconLoader, Alert } from '@supabase/ui'+import { PermissionAction } from '@supabase/shared-types/out/constants'import { NextPageWithLayout } from 'types'import { passwordStrength } from 'lib/helpers'@@ -36,7 +33,6 @@ import {NotOrganizationOwnerWarning,EmptyPaymentMethodWarning,} from 'components/interfaces/Organization/NewProject'-import { PermissionAction } from '@supabase/shared-types/out/constants'const Wizard: NextPageWithLayout = () => {const router = useRouter()@@ -63,7 +59,7 @@ const Wizard: NextPageWithLayout = () => {const totalFreeProjects = subscriptionStats.total_active_free_projectsconst freeProjectsLimit = ui.profile?.free_project_limit ?? DEFAULT_FREE_PROJECTS_LIMIT- const isOrganizationOwner = currentOrg?.is_owner || !app.organizations.isInitialized+ const isAdmin = checkPermissions(PermissionAction.SQL_INSERT, 'postgres.public.projects')const isEmptyOrganizations = organizations.length <= 0 && app.organizations.isInitializedconst isEmptyPaymentMethod = paymentMethods ? !paymentMethods.length : falseconst isOverFreeProjectLimit = totalFreeProjects >= freeProjectsLimit@@ -71,17 +67,11 @@ const Wizard: NextPageWithLayout = () => {const isSelectFreeTier = dbPricingTierKey === PRICING_TIER_FREE_KEYconst canCreateProject =- currentOrg?.is_owner &&+ isAdmin &&!subscriptionStats.isError &&!subscriptionStats.isLoading &&(!isSelectFreeTier || (isSelectFreeTier && !isOverFreeProjectLimit))- const canCreateProject2 = checkPermissions(- PermissionAction.SQL_INSERT,- 'postgres.public.projects'- )- console.log('CanCreateProject2', currentOrg?.name, canCreateProject2)-const canSubmit =projectName != '' &&passwordStrengthScore >= DEFAULT_MINIMUM_PASSWORD_STRENGTH &&@@ -259,7 +249,7 @@ const Wizard: NextPageWithLayout = () => {</Listbox>)}- {!isOrganizationOwner && <NotOrganizationOwnerWarning />}+ {!isAdmin && <NotOrganizationOwnerWarning />}</Panel.Content>{canCreateProject && (<>@@ -330,7 +320,7 @@ const Wizard: NextPageWithLayout = () => {</Panel.Content></>)}- {currentOrg?.is_owner && (+ {isAdmin && (<Panel.Content className="Form section-block--body has-inputs-centered "><Listboxlabel="Pricing Plan"