Skip to content

Commit

Permalink
change logic for uniqueness check in light verification
Browse files Browse the repository at this point in the history
  • Loading branch information
chabanyknikita committed Oct 23, 2024
1 parent 886213d commit 172a3de
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions internal/service/handlers/verification_callback_light.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,27 @@ func VerificationSignatureCallback(w http.ResponseWriter, r *http.Request) {
return
}

if byNullifier != nil && byNullifier.UserIDHash != verifiedUser.UserIDHash &&
byAnonymousID != nil && byAnonymousID.UserIDHash != verifiedUser.UserIDHash {
Log(r).WithError(err).Errorf("User with anonymous_id [%s] but a different userIDHash already exists", anonymousIDHex)
verifiedUser.Status = "failed_verification"
if byAnonymousID != nil {
if byAnonymousID.UserIDHash != verifiedUser.UserIDHash {
Log(r).WithError(err).Errorf("User with anonymous_id [%s] but a different userIDHash already exists", anonymousIDHex)
verifiedUser.Status = "failed_verification"
return
}
} else {
verifiedUser.Nullifier = nullifierHex
verifiedUser.AnonymousID = anonymousIDHex
}

if byNullifier != nil {
if byNullifier.UserIDHash != verifiedUser.UserIDHash {
Log(r).WithError(err).Errorf("User with nullifier [%s] but a different userIDHash already exists", nullifierHex)
verifiedUser.Status = "failed_verification"
return
}
} else {
verifiedUser.Nullifier = nullifierHex
}
}

if eventData != userIDHash {
Log(r).WithError(err).Errorf("failed to verify user: EventData from pub-signals [%s] != userIdHash from db [%s]", eventData, userIDHash)
verifiedUser.Status = "failed_verification"
Expand Down

0 comments on commit 172a3de

Please sign in to comment.