The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix: add rate limit exhaustion content card for auth email rate limits (#18785)
Joel Leec4f58c7815fb
diff --git a/apps/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx b/apps/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsxindex bbf5def35e5..7730235d0f1 100644--- a/apps/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx+++ b/apps/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx@@ -34,6 +34,7 @@ import EmailRateLimitsAlert from '../EmailRateLimitsAlert'import { urlRegex } from './../Auth.constants'import { defaultDisabledSmtpFormValues } from './SmtpForm.constants'import { generateFormValues, isSmtpEnabled } from './SmtpForm.utils'+import { Markdown } from 'components/interfaces/Markdown'const SmtpForm = () => {const { ui } = useStore()@@ -202,40 +203,44 @@ const SmtpForm = () => {}><FormSection>- <FormSectionContent loading={isLoading}>+ <FormSectionContent className="!col-span-12 !gap-y-2" loading={isLoading}><Toggle- name="ENABLE_SMTP"size="small"- label="Enable Custom SMTP"layout="flex"+ name="ENABLE_SMTP"+ label="Enable Custom SMTP"checked={enableSmtp}disabled={!canUpdateConfig}// @ts-ignoreonChange={(value: boolean) => setEnableSmtp(value)}- descriptionText="Emails will be sent using your custom SMTP provider"+ descriptionText={+ <Markdown+ className="max-w-full [&>p]:text-foreground-lighter"+ content={`Emails will be sent using your custom SMTP provider. Email rate limits can be adjusted [here](/project/${projectRef}/auth/rate-limits).`}+ />+ }/>+ {enableSmtp ? (+ !isValidSmtpConfig && (+ <div className="">+ <Alert_Shadcn_ variant="warning">+ <IconAlertTriangle strokeWidth={2} />+ <AlertTitle_Shadcn_>All fields below must be filled</AlertTitle_Shadcn_>+ <AlertDescription_Shadcn_>+ The following fields must be filled before custom SMTP can be properly+ enabled+ </AlertDescription_Shadcn_>+ </Alert_Shadcn_>+ </div>+ )+ ) : (+ <div className="">+ <EmailRateLimitsAlert />+ </div>+ )}</FormSectionContent></FormSection>- {enableSmtp ? (- !isValidSmtpConfig && (- <div className="mx-8 mb-8 -mt-4">- <Alert_Shadcn_ variant="warning">- <IconAlertTriangle strokeWidth={2} />- <AlertTitle_Shadcn_>All fields below must be filled</AlertTitle_Shadcn_>- <AlertDescription_Shadcn_>- The following fields must be filled before custom SMTP can be properly- enabled- </AlertDescription_Shadcn_>- </Alert_Shadcn_>- </div>- )- ) : (- <div className="mx-8 mb-8 -mt-4">- <EmailRateLimitsAlert />- </div>- )}-<FormSectionvisible={enableSmtp}header={<FormSectionLabel>Sender details</FormSectionLabel>}diff --git a/apps/studio/components/interfaces/Home/ProjectList/ProjectCardStatus.tsx b/apps/studio/components/interfaces/Home/ProjectList/ProjectCardStatus.tsxindex cff9a6adee2..eacdfffe40c 100644--- a/apps/studio/components/interfaces/Home/ProjectList/ProjectCardStatus.tsx+++ b/apps/studio/components/interfaces/Home/ProjectList/ProjectCardStatus.tsx@@ -100,7 +100,7 @@ export const ProjectCardStatus = ({) : (<AlertTriangle strokeWidth={1.5} size={12} />)}- <div className="flex justify-between items-center w-full">+ <div className="flex justify-between items-center w-full gap-x-1"><AlertTitle_Shadcn_ className="text-xs mb-0">{alertTitle}</AlertTitle_Shadcn_><Tooltip.Root delayDuration={0}><Tooltip.Trigger>@@ -112,7 +112,7 @@ export const ProjectCardStatus = ({<divclassName={['rounded bg-alternative py-1 px-2 leading-none shadow',- 'border bg-background',+ 'border bg-background w-[280px]',].join(' ')}><span className="text-xs text-foreground">{alertDescription}</span>diff --git a/apps/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.constants.ts b/apps/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.constants.tsindex fd5f679b2b6..a884c8821ae 100644--- a/apps/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.constants.ts+++ b/apps/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.constants.ts@@ -139,6 +139,34 @@ export const RESOURCE_WARNING_MESSAGES = {buttonText: 'Check usage',metric: 'ram',},+ auth_rate_limit_exhaustion: {+ // [Joel] There is no critical warning as there is no notion of critical rate limits for auth at the moment+ bannerContent: {+ warning: {+ title:+ 'Your project has exceeded email rate limits in the past 24 hours and may not reliably send auth related emails to users',+ description:+ 'Set up a custom SMTP and adjust rate limits where necessary to ensure that emails are sent out reliably.',+ },+ critical: {+ title: undefined,+ description: undefined,+ },+ },+ cardContent: {+ warning: {+ title: 'Your project has exceeded email rate limits',+ description: `You will need to set up a custom SMTP provider and adjust rate limits where necessary`,+ },+ critical: {+ title: undefined,+ description: undefined,+ },+ },+ docsUrl: 'https://supabase.com/docs/guides/platform/going-into-prod#auth-rate-limits',+ buttonText: 'Enable Custom SMTP',+ metric: 'auth_email_rate_limit',+ },multiple_resource_warnings: {bannerContent: {warning: {diff --git a/apps/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.tsx b/apps/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.tsxindex fc07f656e50..6c30301afd8 100644--- a/apps/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.tsx+++ b/apps/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.tsx@@ -81,6 +81,8 @@ const ResourceExhaustionWarningBanner = () => {? '/project/[ref]/settings/[infra-path]': metric === 'disk_space' || metric === 'read_only'? '/project/[ref]/settings/database'+ : metric === 'auth_email_rate_limit'+ ? '/project/[ref]/settings/auth': `/project/[ref]/settings/[infra-path]#${metric}`)?.replace('[ref]', ref ?? 'default')@@ -115,7 +117,9 @@ const ResourceExhaustionWarningBanner = () => {<div className="absolute top-5 right-5 flex items-center space-x-2">{learnMoreUrl !== undefined && (<Button asChild type="default" icon={<IconExternalLink />}>- <Link href={learnMoreUrl}>Learn more</Link>+ <a href={learnMoreUrl} target="_blank" rel="noreferrer">+ Learn more+ </a></Button>)}{correctionUrl !== undefined && (