feat: send security lockout emails to all admin users
This commit is contained in:
@@ -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.' }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user