Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
alnr committed Jul 1, 2024
1 parent 2bd6ae7 commit 41e12dc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions corpx/faker.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
"github.com/ory/kratos/session"
"github.com/ory/kratos/ui/node"
"github.com/ory/kratos/x"
"github.com/ory/x/pointerx"
"github.com/ory/x/randx"
"github.com/ory/x/stringsx"
)

var setup sync.Once
Expand All @@ -31,13 +31,13 @@ func registerFakes() {
_ = faker.SetRandomMapAndSliceSize(4)

if err := faker.AddProvider("ptr_geo_location", func(v reflect.Value) (interface{}, error) {
return stringsx.GetPointer("Munich, Germany"), nil
return pointerx.Ptr("Munich, Germany"), nil
}); err != nil {
panic(err)
}

if err := faker.AddProvider("ptr_ipv4", func(v reflect.Value) (interface{}, error) {
return stringsx.GetPointer(faker.IPv4()), nil
return pointerx.Ptr(faker.IPv4()), nil
}); err != nil {
panic(err)
}
Expand Down
5 changes: 3 additions & 2 deletions persistence/sql/persister_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/ory/herodot"
"github.com/ory/x/dbal"
"github.com/ory/x/pointerx"

"github.com/gobuffalo/pop/v6"
"github.com/gofrs/uuid"
Expand Down Expand Up @@ -286,10 +287,10 @@ func (p *Persister) UpsertSession(ctx context.Context, s *session.Session) (err
device.NID = s.NID

if device.Location != nil {
device.Location = stringsx.GetPointer(stringsx.TruncateByteLen(*device.Location, SessionDeviceLocationMaxLength))
device.Location = pointerx.Ptr(stringsx.TruncateByteLen(*device.Location, SessionDeviceLocationMaxLength))
}
if device.UserAgent != nil {
device.UserAgent = stringsx.GetPointer(stringsx.TruncateByteLen(*device.UserAgent, SessionDeviceUserAgentMaxLength))
device.UserAgent = pointerx.Ptr(stringsx.TruncateByteLen(*device.UserAgent, SessionDeviceUserAgentMaxLength))
}

if err := p.DevicePersister.CreateDevice(ctx, device); err != nil {
Expand Down
8 changes: 4 additions & 4 deletions session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

"github.com/ory/x/httpx"
"github.com/ory/x/pagination/keysetpagination"
"github.com/ory/x/stringsx"
"github.com/ory/x/pointerx"

"github.com/pkg/errors"

Expand Down Expand Up @@ -282,12 +282,12 @@ func (s *Session) Activate(r *http.Request, i *identity.Identity, c lifespanProv
func (s *Session) SetSessionDeviceInformation(r *http.Request) {
device := Device{
SessionID: s.ID,
IPAddress: stringsx.GetPointer(httpx.ClientIP(r)),
IPAddress: pointerx.Ptr(httpx.ClientIP(r)),
}

agent := r.Header["User-Agent"]
if len(agent) > 0 {
device.UserAgent = stringsx.GetPointer(strings.Join(agent, " "))
device.UserAgent = pointerx.Ptr(strings.Join(agent, " "))
}

var clientGeoLocation []string
Expand All @@ -297,7 +297,7 @@ func (s *Session) SetSessionDeviceInformation(r *http.Request) {
if r.Header.Get("Cf-Ipcountry") != "" {
clientGeoLocation = append(clientGeoLocation, r.Header.Get("Cf-Ipcountry"))
}
device.Location = stringsx.GetPointer(strings.Join(clientGeoLocation, ", "))
device.Location = pointerx.Ptr(strings.Join(clientGeoLocation, ", "))

s.Devices = append(s.Devices, device)
}
Expand Down

0 comments on commit 41e12dc

Please sign in to comment.