Compare commits

..

2 Commits

Author SHA1 Message Date
Hermes 2fda27a329 fix(login): request-otp must insert otp_code (NOT NULL) for send_pin email
Full edge-fn sync clobbered a live hotfix: repo request-otp only wrote
otp_code_hash, but login_otps.otp_code is NOT NULL, so every request
failed with 'Failed to generate OTP' and no PIN email was sent. Restore
writing otp_code (n8n send_pin trigger emails it; verify still uses hash).
2026-08-21 16:35:04 +02:00
Hermes a505ce6ca7 merge main (edge function fix) 2026-08-21 14:25:21 +02:00
1 changed files with 4 additions and 1 deletions

View File

@ -89,11 +89,14 @@ Deno.serve(async (request) => {
const clientIp = getClientIp(request);
const userAgent = request.headers.get("user-agent") || null;
// Insert with OTP hash only — no plaintext in DB
// Insert with OTP hash for verification. otp_code (plaintext) is also stored
// because DB has it NOT NULL and the send_pin trigger (→ n8n webhook) emails
// this exact code to the user. verify-otp still compares the SHA-256 hash.
const { error: insertError } = await supabase.from("login_otps").insert({
email,
name: userName,
role: userRole,
otp_code: otp,
otp_code_hash: otpCodeHash,
ip_address: clientIp,
user_agent: userAgent,