Files
supabase/apps/studio/components/interfaces/Auth/SmtpForm/SmtpForm.utils.ts
T
Ivan Vasilov 436bdb10ae chore: Move the studio app to apps/studio (#18915)
* Move all studio files from /studio to /apps/studio.

* Move studio specific prettier ignores.

* Fix the ui references from studio.

* Fix the css imports.

* Fix all package.json issues.

* Fix the prettier setup for the studio app.

* Add .turbo folder to prettierignore.

* Fix the github workflows.
2023-11-15 12:38:55 +01:00

34 lines
1014 B
TypeScript

import { components } from 'data/api'
type AuthConfig = components['schemas']['GoTrueConfig']
interface AuthConfigForm extends AuthConfig {
ENABLE_SMTP: boolean
}
export const isSmtpEnabled = (config?: Partial<AuthConfig>): boolean => {
return !!(
config?.SMTP_ADMIN_EMAIL &&
config?.SMTP_SENDER_NAME &&
config?.SMTP_USER &&
config?.SMTP_HOST &&
config?.SMTP_PASS &&
config?.SMTP_PORT &&
(config?.SMTP_MAX_FREQUENCY ?? 0) >= 0
)
}
export const generateFormValues = (config?: Partial<AuthConfig>): Partial<AuthConfigForm> => {
return {
ENABLE_SMTP: isSmtpEnabled(config),
SMTP_ADMIN_EMAIL: config?.SMTP_ADMIN_EMAIL ?? '',
SMTP_SENDER_NAME: config?.SMTP_SENDER_NAME ?? '',
SMTP_USER: config?.SMTP_USER ?? '',
SMTP_HOST: config?.SMTP_HOST ?? '',
SMTP_PASS: config?.SMTP_PASS ?? '',
SMTP_PORT: config?.SMTP_PORT ?? '465',
SMTP_MAX_FREQUENCY: config?.SMTP_MAX_FREQUENCY ?? 60,
RATE_LIMIT_EMAIL_SENT: config?.RATE_LIMIT_EMAIL_SENT ?? 30,
}
}