@@ -82,13 +82,13 @@ type Session struct {
82
82
Identity * identity.Identity `json:"identity" faker:"identity" db:"-" belongs_to:"identities" fk_id:"IdentityID"`
83
83
84
84
// IP address of the machine where the session was initiated
85
- ClientIPAddress string `json:"client_ip_address" db:"client_ip_address"`
85
+ ClientIPAddress * string `json:"client_ip_address" db:"client_ip_address"`
86
86
87
87
// User Agent
88
- UserAgent string `json:"user_agent" db:"user_agent"`
88
+ UserAgent * string `json:"user_agent" db:"user_agent"`
89
89
90
90
// Geo Location where the session was initiated
91
- GeoLocation string `json:"geo_location" db:"geo_location"`
91
+ GeoLocation * string `json:"geo_location" db:"geo_location"`
92
92
93
93
// IdentityID is a helper struct field for gobuffalo.pop.
94
94
IdentityID uuid.UUID `json:"-" faker:"-" db:"identity_id"`
@@ -196,14 +196,14 @@ func (s *Session) Activate(r *http.Request, i *identity.Identity, c lifespanProv
196
196
}
197
197
198
198
if trueClientIP := r .Header .Get ("True-Client-IP" ); trueClientIP != "" {
199
- s .ClientIPAddress = trueClientIP
199
+ s .ClientIPAddress = & trueClientIP
200
200
} else if realClientIP := r .Header .Get ("X-Real-IP" ); realClientIP != "" {
201
- s .ClientIPAddress = realClientIP
201
+ s .ClientIPAddress = & realClientIP
202
202
} else if forwardedIP := r .Header .Get ("X-Forwarded-For" ); forwardedIP != "" {
203
203
// TODO: Use x lib implementation to parse client IP address from the header string
204
- s .ClientIPAddress = forwardedIP
204
+ s .ClientIPAddress = & forwardedIP
205
205
} else {
206
- s .ClientIPAddress = r .RemoteAddr
206
+ s .ClientIPAddress = & r .RemoteAddr
207
207
}
208
208
209
209
clientGeoLocation := []string {r .Header .Get ("Cf-Ipcity" ), r .Header .Get ("Cf-Ipcountry" )}
0 commit comments