Skip to content

Commit

Permalink
Merge pull request #6 from rarimo/fix/get_provider_panic
Browse files Browse the repository at this point in the history
Check user is not nil before getting Provider Data
  • Loading branch information
artemskriabin authored Apr 5, 2024
2 parents 5517b33 + c8faaf4 commit deb4dd4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func GetProviderByIdentityId(w http.ResponseWriter, r *http.Request) {

provider, err := KYCService(r).GetProviderByIdentityId(req)
switch {
case errors.Is(err, identityproviders.ErrProviderNotFound):
case errors.Is(err, identityproviders.ErrProviderNotFound), errors.Is(err, identityproviders.ErrUserNotFound):
Log(r).WithField("reason", err).Debug("Not found")
ape.RenderErr(w, problems.NotFound())
return
Expand Down
4 changes: 4 additions & 0 deletions internal/service/core/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ func (k *kycService) GetProviderByIdentityId(req *requests.GetProviderByIdentity
return "", errors.Wrap(err, "failed to get user from db with provided identityID")
}

if user == nil {
return "", identityproviders.ErrUserNotFound
}

domainData := unstopdom.Domain{}
if err := json.Unmarshal(user.ProviderData, &domainData); err != nil {
return "", errors.Wrap(err, "failed to unmarshal json")
Expand Down
1 change: 1 addition & 0 deletions internal/service/core/identity_providers/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var (

// Not found errors
ErrProviderNotFound = errors.New("provider not found")
ErrUserNotFound = errors.New("user not found")
)

type IdentityProviderName string
Expand Down

0 comments on commit deb4dd4

Please sign in to comment.