Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pkg/internal/unit21/evaluate_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package unit21

import (
"fmt"
"testing"
"time"

Expand Down
12 changes: 11 additions & 1 deletion pkg/service/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down