Skip to content

Commit

Permalink
retun error from isTwinVerified
Browse files Browse the repository at this point in the history
  • Loading branch information
Eslam-Nawara committed Oct 30, 2024
1 parent 799c94a commit b5df945
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions grid-client/deployer/tf_plugin_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,9 @@ func NewTFPluginClient(

// make sure the account used is verified
check := func() error {
if !isTwinVerified(twinID, tfPluginClient.Network) {
if ok, err := isTwinVerified(twinID, tfPluginClient.Network); err != nil {
return err
} else if !ok {
return fmt.Errorf("user with twin id %d is not verified", twinID)
}
return nil
Expand Down Expand Up @@ -364,7 +366,7 @@ func generateSessionID() string {
}

// isTwinVerified makes sure the twin used is verified
func isTwinVerified(twinID uint32, net string) (verified bool) {
func isTwinVerified(twinID uint32, net string) (verified bool, err error) {
const verifiedStatus = "VERIFIED"

verificationServiceURL, err := url.JoinPath(KycURLs[net], "/api/v1/status")
Expand Down Expand Up @@ -392,8 +394,7 @@ func isTwinVerified(twinID uint32, net string) (verified bool) {
defer response.Body.Close()

if response.StatusCode != http.StatusOK {
log.Error().Msg("failed to get user status")
return
return verified, errors.New("failed to get twin verification status")
}

var result struct{ Result struct{ Status string } }
Expand All @@ -403,5 +404,5 @@ func isTwinVerified(twinID uint32, net string) (verified bool) {
return
}

return result.Result.Status == verifiedStatus
return result.Result.Status == verifiedStatus, nil
}

0 comments on commit b5df945

Please # to comment.