Add customer login activity logging

- Add CustomerLoginLog model to track customer login attempts
- Record successful and failed customer logins
- Capture email, IP address, and user agent for each attempt
- Create /admin/customer-login-logs page to view activity
- Show login stats (successes, failures, active customers)
- Display browser/device and IP for each login attempt
- Add "Customer login activity" link to admin menu
- Monitor customer access patterns and detect suspicious activity
- Last 30 days active customer count

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
Andymick
2026-07-16 21:43:09 +01:00
co-authored by Claude Haiku 4.5
parent ea6f9d2e25
commit e69759081c
4 changed files with 168 additions and 1 deletions
+11
View File
@@ -393,3 +393,14 @@ model AdminLoginLog {
userAgent String?
success Boolean @default(true) // false for failed login attempts
}
// Audit log for customer logins — tracks customer account access
model CustomerLoginLog {
id String @id @default(cuid())
customerId String?
email String // captured for failed attempts where customer doesn't exist
loginAt DateTime @default(now())
ipAddress String?
userAgent String?
success Boolean @default(true) // false for failed login attempts
}