diff --git a/pkg/internal/unit21/evaluate_test.go b/pkg/internal/unit21/evaluate_test.go index df1bf051..565cf61a 100644 --- a/pkg/internal/unit21/evaluate_test.go +++ b/pkg/internal/unit21/evaluate_test.go @@ -1,7 +1,6 @@ package unit21 import ( - "fmt" "testing" "time" diff --git a/pkg/service/user.go b/pkg/service/user.go index b59eec87..502b29be 100644 --- a/pkg/service/user.go +++ b/pkg/service/user.go @@ -2,11 +2,13 @@ package service import ( "os" + "time" "github.com/String-xyz/string-api/pkg/internal/common" "github.com/String-xyz/string-api/pkg/model" "github.com/String-xyz/string-api/pkg/repository" "github.com/pkg/errors" + "github.com/rs/zerolog/log" ) type UserRequest = model.UserRequest @@ -98,11 +100,19 @@ func (u user) Create(request model.WalletSignaturePayloadSigned) (UserCreateResp // create device only if there is a visitor device, err := u.device.CreateDeviceIfNeeded(user.Id, request.Fingerprint.VisitorId, request.Fingerprint.RequestId) - if err != nil && errors.Cause(err).Error() != "not found" { return resp, common.StringError(err) } + if device.Fingerprint != "" { + // validate that device on user creation + now := time.Now() + err = u.repos.Device.Update(device.Id, model.DeviceUpdates{ValidatedAt: &now}) + if err == nil { + log.Err(err).Msg("Failed to verify user device") + } + } + jwt, err := u.auth.GenerateJWT(user.Id, device) if err != nil { return resp, common.StringError(err)