Skip to content

Commit

Permalink
Merge pull request #38 from rarimo/fix/verify_passport
Browse files Browse the repository at this point in the history
Fix proof country validation
  • Loading branch information
violog authored Jun 27, 2024
2 parents 1970264 + b0ae0d9 commit 68aa707
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions internal/service/handlers/verify_passport.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,17 @@ func VerifyPassport(w http.ResponseWriter, r *http.Request) {
balAID = *balance.AnonymousID
}

proofCountry, err := requests.ExtractCountry(*proof)
if err != nil {
log.WithError(err).Error("failed to extract country while proof was successfully verified")
ape.RenderErr(w, problems.InternalError())
return
}

err = validation.Errors{
"data/attributes/country": validation.Validate(*balance.Country, validation.Required, validation.In(country)),
"data/attributes/anonymous_id": validation.Validate(anonymousID, validation.Required, validation.In(balAID)),
"data/attributes/country": validation.Validate(*balance.Country, validation.Required, validation.In(country)),
"data/attributes/anonymous_id": validation.Validate(anonymousID, validation.Required, validation.In(balAID)),
"data/attributes/proof/pub_signals/country": validation.Validate(proofCountry, validation.Required, validation.In(*balance.Country)),
}.Filter()
if err != nil {
ape.RenderErr(w, problems.BadRequest(err)...)
Expand Down

0 comments on commit 68aa707

Please sign in to comment.