Log successful login attempts in addition to failed ones

This commit is contained in:
Matt 2021-12-15 23:05:51 +00:00 committed by GitHub
parent 7ee8142b38
commit da0d1cb754
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -455,10 +455,11 @@ func handleLogin(w http.ResponseWriter, r *http.Request) {
return
}
var ip net.IP
ip, err = realIP(r)
if len(cookie) == 0 {
var ip net.IP
ip, err = realIP(r)
if err != nil {
log.Info("auth: getting real ip from request: %s", err)
} else if ip == nil {
@ -473,6 +474,15 @@ func handleLogin(w http.ResponseWriter, r *http.Request) {
return
}
if err != nil {
log.Info("auth: getting real ip from request: %s", err)
} else if ip == nil {
// Technically shouldn't happen.
log.Info("auth: user %q successfully logged in from unknown ip", req.Name)
} else {
log.Info("auth: user %q successfully logged in from ip %q", req.Name, ip)
}
w.Header().Set("Set-Cookie", cookie)