fix: sync credentials services between backend and frontend

- Update ListConfiguredServices to use correct service names
- Add fcm_service_account, appwrite, smtp to BootstrapCredentials
- Remove unused payment_gateway from frontend schema
- Rename firebase to fcm_service_account in frontend
This commit is contained in:
Tiago Yamamoto 2026-02-23 16:20:25 -06:00
parent f061763ae4
commit fa1d397c01
2 changed files with 49 additions and 42 deletions

View file

@ -148,15 +148,16 @@ type ConfiguredService struct {
// ListConfiguredServices returns all configured services without revealing credential values
func (s *CredentialsService) ListConfiguredServices(ctx context.Context) ([]ConfiguredService, error) {
// Define all supported services
// Define all supported services - must match BootstrapCredentials keys
allServices := []string{
"appwrite",
"stripe",
"firebase",
"cloudflare",
"smtp",
"s3",
"storage",
"cloudflare_config",
"cpanel",
"lavinmq",
"appwrite",
"fcm_service_account",
"smtp",
}
query := `
@ -268,14 +269,6 @@ func (s *CredentialsService) BootstrapCredentials(ctx context.Context) error {
"publishableKey": os.Getenv("STRIPE_PUBLISHABLE_KEY"),
}
},
"payment_gateway": func() interface{} {
return map[string]string{
"merchantId": os.Getenv("PAYMENT_GATEWAY_MERCHANT_ID"),
"apiKey": os.Getenv("PAYMENT_GATEWAY_API_KEY"),
"endpoint": os.Getenv("PAYMENT_GATEWAY_ENDPOINT"),
"webhookSecret": os.Getenv("PAYMENT_GATEWAY_WEBHOOK_SECRET"),
}
},
"storage": func() interface{} {
return map[string]string{
"endpoint": os.Getenv("AWS_ENDPOINT"),
@ -303,6 +296,29 @@ func (s *CredentialsService) BootstrapCredentials(ctx context.Context) error {
"apiToken": os.Getenv("CPANEL_API_TOKEN"),
}
},
"appwrite": func() interface{} {
return map[string]string{
"endpoint": os.Getenv("APPWRITE_ENDPOINT"),
"projectId": os.Getenv("APPWRITE_PROJECT_ID"),
"apiKey": os.Getenv("APPWRITE_API_KEY"),
}
},
"fcm_service_account": func() interface{} {
return map[string]string{
"serviceAccountJson": os.Getenv("FCM_SERVICE_ACCOUNT_JSON"),
}
},
"smtp": func() interface{} {
return map[string]string{
"host": os.Getenv("SMTP_HOST"),
"port": os.Getenv("SMTP_PORT"),
"username": os.Getenv("SMTP_USERNAME"),
"password": os.Getenv("SMTP_PASSWORD"),
"from_email": os.Getenv("SMTP_FROM_EMAIL"),
"from_name": os.Getenv("SMTP_FROM_NAME"),
"secure": os.Getenv("SMTP_SECURE"),
}
},
}
for service, getEnvData := range services {

View file

@ -128,7 +128,7 @@ export default function SettingsPage() {
}
}
// Predefined schemas for known services (Copied from CredentialsPage)
// Predefined schemas for known services (must match backend BootstrapCredentials)
const schemas: Record<string, { label: string, fields: { key: string, label: string, type?: string }[] }> = {
stripe: {
label: "Stripe",
@ -138,15 +138,6 @@ export default function SettingsPage() {
{ key: "publishableKey", label: "Publishable Key (pk_...)", type: "text" },
]
},
payment_gateway: {
label: "Gateway de Pagamento (Fictício)",
fields: [
{ key: "merchantId", label: "Merchant ID", type: "text" },
{ key: "apiKey", label: "API Key", type: "password" },
{ key: "endpoint", label: "Endpoint URL", type: "text" },
{ key: "webhookSecret", label: "Webhook Secret", type: "password" },
]
},
storage: {
label: "AWS S3 / Compatible",
fields: [
@ -157,6 +148,13 @@ export default function SettingsPage() {
{ key: "secretKey", label: "Secret Access Key", type: "password" },
]
},
cloudflare_config: {
label: "Cloudflare",
fields: [
{ key: "apiToken", label: "API Token", type: "password" },
{ key: "zoneId", label: "Zone ID", type: "text" },
]
},
cpanel: {
label: "cPanel Integration",
fields: [
@ -171,11 +169,18 @@ export default function SettingsPage() {
{ key: "amqpUrl", label: "AMQP URL", type: "password" },
]
},
cloudflare_config: {
label: "Cloudflare",
appwrite: {
label: "Appwrite",
fields: [
{ key: "apiToken", label: "API Token", type: "password" },
{ key: "zoneId", label: "Zone ID", type: "text" },
{ key: "endpoint", label: "Endpoint", type: "text" },
{ key: "projectId", label: "Project ID", type: "text" },
{ key: "apiKey", label: "API Key", type: "password" },
]
},
fcm_service_account: {
label: "Firebase Cloud Messaging",
fields: [
{ key: "serviceAccountJson", label: "Service Account JSON Content", type: "textarea" }
]
},
smtp: {
@ -190,20 +195,6 @@ export default function SettingsPage() {
{ key: "secure", label: "Use TLS", type: "checkbox" }
]
},
appwrite: {
label: "Appwrite",
fields: [
{ key: "endpoint", label: "Endpoint", type: "text" },
{ key: "projectId", label: "Project ID", type: "text" },
{ key: "apiKey", label: "API Key", type: "password" },
]
},
firebase: {
label: "Firebase (JSON)",
fields: [
{ key: "serviceAccountJson", label: "Service Account JSON Content", type: "textarea" }
]
}
}
const configuredMap = new Map(credentials.map((svc) => [svc.service_name, svc]))