Replace r.RemoteAddr with r.Header.Get("X-Forwarded-For")

This commit is contained in:
Andrea Fazzi 2021-01-10 18:04:34 +01:00
parent ecf4c73f4b
commit 02fc36f723

View file

@ -1,7 +1,6 @@
package orm
import (
"log"
"net/http"
)
@ -54,12 +53,11 @@ func (um UserModifier) UpdatedBy() *User {
func WriteCreator(r *http.Request, modifier Modifier) {
modifier.SetCreatorID(getUserIDFromTokenAsUint(r))
modifier.SetCreatorRole(getUserRole(r))
modifier.SetCreatorIP(r.RemoteAddr)
modifier.SetCreatorIP(r.Header.Get("X-Forwarded-For"))
}
func WriteUpdater(r *http.Request, modifier Modifier) {
modifier.SetUpdaterID(getUserIDFromTokenAsUint(r))
modifier.SetUpdaterRole(getUserRole(r))
modifier.SetUpdaterIP(r.RemoteAddr)
log.Printf("Forwarded IP address: %v", r.Header.Get("X-Forwarded-For"))
modifier.SetUpdaterIP(r.Header.Get("X-Forwarded-For"))
}