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
1 changed files with 12 additions and 2 deletions

View File

@ -456,9 +456,10 @@ func handleLogin(w http.ResponseWriter, r *http.Request) {
return
}
if len(cookie) == 0 {
var ip net.IP
ip, err = realIP(r)
if len(cookie) == 0 {
if err != nil {
log.Info("auth: getting real ip from request: %s", err)
} else if ip == nil {
@ -474,6 +475,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)
w.Header().Set("Cache-Control", "no-store, no-cache, must-revalidate, proxy-revalidate")