Skip to content

Commit

Permalink
Remove shared hash and external anonimuos id from unverified balance …
Browse files Browse the repository at this point in the history
…to allow user to attach them to verified balance
  • Loading branch information
artemskriabin committed Oct 23, 2024
1 parent 371ec23 commit df7798e
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions internal/service/handlers/verify_internal_passport.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,25 @@ func VerifyInternalPassport(w http.ResponseWriter, r *http.Request) {
return
}
if bySharedHash != nil && bySharedHash.Nullifier != balance.Nullifier {
log.Warn("Balance with the same shared hash already exists")
ape.RenderErr(w, problems.Forbidden())
return
if proof == nil {
log.Warn("Balance with the same shared hash already exists")
ape.RenderErr(w, problems.Forbidden())
return
}

// transfer bySharedHash balance to current balance
// because we have proof that user is registered on smart contract
// it is main user account, so just remove shared hash and external id from unverified balance
// it allows user to attach external passport to his verified balance
err = BalancesQ(r).FilterBySharedHash(*sharedHash).Update(map[string]any{
data.ColSharedHash: nil,
data.ColExternalAID: nil,
})
if err != nil {
log.WithError(err).Error("Failed to remove shared hash from unverified balance")
ape.RenderErr(w, problems.InternalError())
return
}
}

if byAnonymousID != nil {
Expand Down

0 comments on commit df7798e

Please sign in to comment.