feat: send security lockout emails to all admin users

This commit is contained in:
DanielS
2026-08-11 00:20:07 +02:00
parent 696528283a
commit 6177c0cde1

View File

@@ -35,8 +35,23 @@ export async function signIn(email: string, password: string) {
.from('users') .from('users')
.update({ role: 'gesperrt' }) .update({ role: 'gesperrt' })
.eq('email', email) .eq('email', email)
// Notify admin // Notify all admins
await sendLockoutEmail('info@hephex.de') try {
const adminClient = createAdminClient()
const { data: admins } = await adminClient
.from('users')
.select('email')
.eq('role', 'admin')
if (admins && admins.length > 0) {
const adminEmails = admins.map(a => a.email).filter(Boolean)
for (const adminEmail of adminEmails) {
await sendLockoutEmail(adminEmail)
}
}
} catch (mailError) {
console.error('Failed to notify admins of lockout:', mailError)
}
return { success: false, error: 'Konto gesperrt nach 5 Fehlversuchen.' } return { success: false, error: 'Konto gesperrt nach 5 Fehlversuchen.' }
} }