fix(setup): make SMTP optional and adjust setup check
This commit is contained in:
@@ -44,14 +44,13 @@ export function SetupWizard() {
|
|||||||
adminForm.firstName.trim().length > 0 &&
|
adminForm.firstName.trim().length > 0 &&
|
||||||
adminForm.lastName.trim().length > 0
|
adminForm.lastName.trim().length > 0
|
||||||
|
|
||||||
// Validation checks for SMTP form
|
// Validation checks for SMTP form (optional step)
|
||||||
const isSmtpFormValid =
|
const isSmtpFormValid =
|
||||||
smtpForm.host.trim().length > 0 &&
|
smtpForm.host.trim().length === 0 ||
|
||||||
!isNaN(Number(smtpForm.port)) &&
|
(!isNaN(Number(smtpForm.port)) && smtpForm.user.trim().length > 0)
|
||||||
smtpForm.user.trim().length > 0
|
|
||||||
|
|
||||||
const handleFinishSetup = async () => {
|
const handleFinishSetup = async () => {
|
||||||
if (!isAdminFormValid || !isSmtpFormValid) return
|
if (!isAdminFormValid) return
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
setErrorMsg('')
|
setErrorMsg('')
|
||||||
|
|
||||||
|
|||||||
@@ -34,10 +34,10 @@ export async function isSetupNeeded(): Promise<boolean> {
|
|||||||
|
|
||||||
if (authError) {
|
if (authError) {
|
||||||
console.error('Error checking auth users list:', authError)
|
console.error('Error checking auth users list:', authError)
|
||||||
return false
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (authData.users.length > 0) {
|
if (authData && authData.users && authData.users.length > 0) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,13 +48,13 @@ export async function isSetupNeeded(): Promise<boolean> {
|
|||||||
|
|
||||||
if (dbError) {
|
if (dbError) {
|
||||||
console.error('Error checking users table status:', dbError)
|
console.error('Error checking users table status:', dbError)
|
||||||
return false
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return count === 0
|
return count === 0
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Exception checking setup status:', e)
|
console.error('Exception checking setup status:', e)
|
||||||
return false
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +113,8 @@ export async function completeSetup(
|
|||||||
console.error('Error updating admin profile:', profileError)
|
console.error('Error updating admin profile:', profileError)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. Store SMTP configuration in public.settings
|
// 5. Store SMTP configuration in public.settings (optional)
|
||||||
|
if (smtpData.host && smtpData.host.trim().length > 0) {
|
||||||
const { error: smtpError } = await admin
|
const { error: smtpError } = await admin
|
||||||
.from('settings')
|
.from('settings')
|
||||||
.upsert({
|
.upsert({
|
||||||
@@ -128,7 +129,7 @@ export async function completeSetup(
|
|||||||
|
|
||||||
if (smtpError) {
|
if (smtpError) {
|
||||||
console.error('Error saving SMTP settings:', smtpError)
|
console.error('Error saving SMTP settings:', smtpError)
|
||||||
return { success: false, error: `Fehler beim Speichern der SMTP-Einstellungen: ${smtpError.message}` }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
revalidatePath('/')
|
revalidatePath('/')
|
||||||
|
|||||||
Reference in New Issue
Block a user