Fix API token mapping and add extensive debug logging
- Fixed api_token vs mailketing_api_token column mapping - Added comprehensive debug logging to send-auth-otp - Added fallback logic for missing settings fields - Improved error messages for troubleshooting 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
157
supabase/migrations/20250102000004_insert_auth_template.sql
Normal file
157
supabase/migrations/20250102000004_insert_auth_template.sql
Normal file
@@ -0,0 +1,157 @@
|
||||
-- ============================================================================
|
||||
-- Insert Auth Email Verification Template (Fixed)
|
||||
-- ============================================================================
|
||||
|
||||
-- First, let's see what columns the table actually has
|
||||
-- This will help us insert correctly
|
||||
|
||||
-- Check if template exists
|
||||
DO $$
|
||||
DECLARE
|
||||
template_count int;
|
||||
BEGIN
|
||||
SELECT COUNT(*) INTO template_count
|
||||
FROM notification_templates
|
||||
WHERE key = 'auth_email_verification';
|
||||
|
||||
IF template_count = 0 THEN
|
||||
-- Template doesn't exist, insert it
|
||||
INSERT INTO notification_templates (
|
||||
key,
|
||||
name,
|
||||
is_active,
|
||||
email_subject,
|
||||
email_body_html
|
||||
) VALUES (
|
||||
'auth_email_verification',
|
||||
'Verifikasi Email - OTP',
|
||||
true,
|
||||
'Kode Verifikasi Email Anda - {platform_name}',
|
||||
'---
|
||||
<!DOCTYPE html>
|
||||
<html lang="id">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Verifikasi Email</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||
background-color: #f5f5f5;
|
||||
margin: 0;
|
||||
padding: 20px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.container {
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
background: white;
|
||||
border: 3px solid #000;
|
||||
box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
.header {
|
||||
background: #000;
|
||||
color: #fff;
|
||||
padding: 30px;
|
||||
text-align: center;
|
||||
}
|
||||
.header h1 {
|
||||
margin: 0;
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
}
|
||||
.content {
|
||||
padding: 30px;
|
||||
}
|
||||
.greeting {
|
||||
font-size: 18px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.message {
|
||||
margin-bottom: 30px;
|
||||
color: #333;
|
||||
}
|
||||
.otp-container {
|
||||
background: #f9f9f9;
|
||||
border: 2px dashed #000;
|
||||
padding: 30px;
|
||||
text-align: center;
|
||||
margin: 30px 0;
|
||||
}
|
||||
.otp-code {
|
||||
font-size: 36px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 8px;
|
||||
color: #000;
|
||||
font-family: "Courier New", monospace;
|
||||
margin: 20px 0;
|
||||
}
|
||||
.expiry {
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.instructions {
|
||||
background: #fffbeb;
|
||||
border-left: 4px solid #f59e0b;
|
||||
padding: 15px;
|
||||
margin: 20px 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
.footer {
|
||||
background: #f9f9f9;
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
border-top: 2px solid #000;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h1>🔐 Verifikasi Email</h1>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<p class="greeting">Halo {nama},</p>
|
||||
|
||||
<p class="message">
|
||||
Terima kasih telah mendaftar di <strong>{platform_name}</strong>!
|
||||
Gunakan kode OTP berikut untuk memverifikasi alamat email Anda:
|
||||
</p>
|
||||
|
||||
<div class="otp-container">
|
||||
<div class="otp-code">{otp_code}</div>
|
||||
<div class="expiry">⏰ Berlaku selama {expiry_minutes} menit</div>
|
||||
</div>
|
||||
|
||||
<div class="instructions">
|
||||
<strong>Cara menggunakan:</strong><br>
|
||||
1. Salin kode 6 digit di atas<br>
|
||||
2. Kembali ke halaman pendaftaran<br>
|
||||
3. Masukkan kode tersebut pada form verifikasi
|
||||
</div>
|
||||
|
||||
<p class="message" style="margin-top: 30px;">
|
||||
Jika Anda tidak merasa mendaftar di {platform_name},
|
||||
abaikan email ini dengan aman.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
<p>Email ini dikirim ke {email}</p>
|
||||
<p>© {year} {platform_name}. Semua hak dilindungi.</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
---'
|
||||
);
|
||||
|
||||
RAISE NOTICE 'Auth email verification template inserted successfully';
|
||||
ELSE
|
||||
RAISE NOTICE 'Template already exists, skipping insertion';
|
||||
END IF;
|
||||
END $$;
|
||||
Reference in New Issue
Block a user