23 lines
447 B
Go
23 lines
447 B
Go
package storage
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
|
|
"synlotto-website/logging"
|
|
)
|
|
|
|
func LogLoginAttempt(r *http.Request, username string, success bool) {
|
|
ip := r.RemoteAddr
|
|
userAgent := r.UserAgent()
|
|
|
|
_, err := db.Exec(
|
|
`INSERT INTO audit_login (username, success, ip, user_agent, timestamp)
|
|
VALUES (?, ?, ?, ?, ?)`,
|
|
username, success, ip, userAgent, time.Now().UTC(),
|
|
)
|
|
if err != nil {
|
|
logging.Info("❌ Failed to log login:", err)
|
|
}
|
|
}
|