Skip to content

Commit

Permalink
fix response struct
Browse files Browse the repository at this point in the history
  • Loading branch information
Eslam-Nawara committed Oct 27, 2024
1 parent d036a8b commit d14cc3a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions pkg/environment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ var (
"https://graphql.dev.grid.tf/graphql",
"https://graphql.02.dev.grid.tf/graphql",
},
KycURL: "https://kyc1.gent01.dev.grid.tf",
KycURL: "",
}

envTest = Environment{
Expand Down Expand Up @@ -197,7 +197,7 @@ var (
"https://graphql.grid.tf/graphql",
"https://graphql.02.grid.tf/graphql",
},
KycURL: "",
KycURL: "https://kyc1.gent01.dev.grid.tf",
}
)

Expand Down
19 changes: 11 additions & 8 deletions pkg/provision/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -1185,10 +1185,7 @@ func (e *NativeEngine) GetWorkloadStatus(id string) (gridtypes.ResultState, bool
// getTwinVerificationState make sure the account used is verified we have the user public key in bytes(pkBytes)
func getTwinVerificationState(twinID uint32) (status string) {
status = "FAILED"
env, err := environment.Get()
if err != nil {
return
}
env := environment.MustGet()

verificationServiceURL, err := url.JoinPath(env.KycURL, "/api/v1/status")
if err != nil {
Expand Down Expand Up @@ -1219,16 +1216,22 @@ func getTwinVerificationState(twinID uint32) (status string) {
return
}

bodyMap := map[string]string{}
err = json.Unmarshal(body, &bodyMap)
var result struct {
Result struct {
Status string `json:"status"`
} `json:"result"`
Error string `json:"error"`
}

err = json.Unmarshal(body, &result)
if err != nil {
return
}

if response.StatusCode != http.StatusOK {
log.Error().Msgf("failed to verify user status: %s", bodyMap["error"])
log.Error().Msgf("failed to verify user status: %s", result.Error)
return
}

return bodyMap["status"]
return result.Result.Status
}

0 comments on commit d14cc3a

Please sign in to comment.