Skip to content

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

fix: issues with double negative keys

Jonathan Summers-Muir93a270d88d4f
diff --git a/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx b/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx
index dd4f6d27dbd..72d19c971ca 100644
--- a/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx
+++ b/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx
@@ -16,6 +16,7 @@ import {
import { useStore } from 'hooks'
import { Enum, Provider } from './AuthProvidersForm.types'
import { ProviderCollapsibleClasses } from './AuthProvidersForm.constants'
+import { createConsoleLogger } from 'configcat-js'
interface Props {
provider: Provider
@@ -28,6 +29,8 @@ const ProviderForm: FC<Props> = ({ provider }) => {
const isActive = authConfig.config[`EXTERNAL_${provider?.title?.toUpperCase()}_ENABLED`]
const INITIAL_VALUES: { [x: string]: string } = {}
+ const doubleNegativeKeys = ['MAILER_AUTOCONFIRM', 'SMS_AUTOCONFIRM']
+
useEffect(() => {
/**
* Construct values for INITIAL_VALUES
@@ -35,13 +38,39 @@ const ProviderForm: FC<Props> = ({ provider }) => {
* as it breaks form. null is not a valid value.
*/
Object.keys(provider.properties).forEach((key) => {
- INITIAL_VALUES[key] = authConfig.config[key] ?? ''
+ /**
+ * when the key is a 'double negative' key,
+ * we must reverse the boolean before adding it to the form
+ */
+ const isDoubleNegative = doubleNegativeKeys.includes(key)
+
+ INITIAL_VALUES[key] = isDoubleNegative
+ ? !authConfig.config[key]
+ : authConfig.config[key] ?? ''
})
}, [provider])
const onSubmit = async (values: any, { setSubmitting }: any) => {
try {
- await authConfig.update(values)
+ /**
+ * payload used to update the auth config
+ */
+ const payload = { ...values }
+
+ /**
+ * when the key is a 'double negative' key,
+ * we must reverse the boolean before the payload can be sent
+ */
+ Object.keys(values).map((x: string) => {
+ if (doubleNegativeKeys.includes(x)) {
+ payload[x] = !values[x]
+ }
+ })
+
+ console.log('payload', payload)
+
+ await authConfig.update(payload)
+
setSubmitting(false)
setOpen(false)
ui.setNotification({ category: 'success', message: 'Successfully updated settings' })
diff --git a/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx b/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx
index 34fe4a975ed..cee34a12c7b 100644
--- a/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx
+++ b/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx
@@ -240,9 +240,9 @@ const SmtpForm = () => {
name="SMTP_MAX_FREQUENCY"
id="SMTP_MAX_FREQUENCY"
min={0}
- label="Rate limit"
- descriptionText="Maximum number of emails sent per hour"
- actions={<span className="text-scale-900 mr-3">emails per hour</span>}
+ label="Minimum interval between emails being sent"
+ descriptionText="How long between each email can a new email be sent via your SMTP server."
+ actions={<span className="text-scale-900 mr-3">seconds</span>}
/>
<Input
name="SMTP_USER"
diff --git a/studio/stores/authConfig/schema/AuthProviders/AuthProvidersFormValidation.tsx b/studio/stores/authConfig/schema/AuthProviders/AuthProvidersFormValidation.tsx
index 01093ed3bec..3db68b4879d 100644
--- a/studio/stores/authConfig/schema/AuthProviders/AuthProvidersFormValidation.tsx
+++ b/studio/stores/authConfig/schema/AuthProviders/AuthProvidersFormValidation.tsx
@@ -38,7 +38,7 @@ const PROVIDER_EMAIL = {
validationSchema: object().shape({
PASSWORD_MIN_LENGTH: number()
.required('A password is required.')
- .min(8, 'Password length must be at least 8 characters long'),
+ .min(6, 'Password length must be at least 6 characters long'),
MAILER_OTP_EXP: number()
.min(0, 'Must be more than 0')
.max(86400, 'Must be no more than 86400')