Skip to content

Commit

Permalink
Fix auth in create balance. Fix points and level accruing after claim.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaptoss committed Jun 18, 2024
1 parent 61017df commit 0717dc8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 0 additions & 2 deletions internal/service/handlers/claim_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ func DoClaimEventUpdates(
if err = referralsQ.New().Insert(refToAdd...); err != nil {
return fmt.Errorf("failed to insert referrals: %w", err)
}

return nil
}

err = balancesQ.FilterByNullifier(balance.Nullifier).Update(map[string]any{
Expand Down
6 changes: 6 additions & 0 deletions internal/service/handlers/create_balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"net/http"

"github.com/rarimo/decentralized-auth-svc/pkg/auth"
"github.com/rarimo/rarime-points-svc/internal/data"
"github.com/rarimo/rarime-points-svc/internal/data/evtypes"
"github.com/rarimo/rarime-points-svc/internal/service/requests"
Expand All @@ -21,6 +22,11 @@ func CreateBalance(w http.ResponseWriter, r *http.Request) {

nullifier := req.Data.ID

if !auth.Authenticates(UserClaims(r), auth.UserGrant(nullifier)) {
ape.RenderErr(w, problems.Unauthorized())
return
}

balance, err := BalancesQ(r).FilterByNullifier(nullifier).Get()
if err != nil {
Log(r).WithError(err).Error("Failed to get balance by nullifier")
Expand Down

0 comments on commit 0717dc8

Please sign in to comment.