chore(auth): add 2FA database logging
Some checks failed
Staging Build / build (push) Has been cancelled
Some checks failed
Staging Build / build (push) Has been cancelled
- capture and log insert errors during 2FA code generation - print verification queries and lookup parameters to console
This commit is contained in:
@@ -185,9 +185,16 @@ async function send2FACodeInternal(userId: string, deviceHash: string, email: st
|
||||
.eq('device_hash', deviceHash)
|
||||
|
||||
// Neuen Code speichern
|
||||
await adminClient
|
||||
const { data: insData, error: insError } = await adminClient
|
||||
.from('device_verification_codes')
|
||||
.insert({ user_id: userId, code, device_hash: deviceHash, expires_at: expiresAt })
|
||||
.select()
|
||||
|
||||
if (insError) {
|
||||
console.error("2FA CODE INSERT ERROR:", insError)
|
||||
} else {
|
||||
console.log("2FA CODE INSERTED:", code, insData)
|
||||
}
|
||||
|
||||
// Mail senden
|
||||
await sendMail({
|
||||
@@ -222,6 +229,7 @@ export async function verifyDevice2FA(userId: string, code: string, deviceHash:
|
||||
const cleanCode = code.trim()
|
||||
|
||||
// Code prüfen (unter Berücksichtigung von Leerzeichen & device_hash)
|
||||
console.log("VERIFYING 2FA: userId =", userId, "code =", cleanCode)
|
||||
const { data: codeEntries, error: codeError } = await adminClient
|
||||
.from('device_verification_codes')
|
||||
.select('*')
|
||||
@@ -231,6 +239,7 @@ export async function verifyDevice2FA(userId: string, code: string, deviceHash:
|
||||
.limit(1)
|
||||
|
||||
const codeEntry = codeEntries && codeEntries.length > 0 ? codeEntries[0] : null
|
||||
console.log("VERIFY 2FA DB RESULT: entry =", codeEntry, "error =", codeError)
|
||||
|
||||
if (codeError || !codeEntry) {
|
||||
// Doppelklick- & Race-Condition Schutz: Prüfen ob das Gerät eben bereits verifiziert wurde
|
||||
|
||||
Reference in New Issue
Block a user