Skip to content

Commit

Permalink
fix: include factor_id in query (supabase#1702)
Browse files Browse the repository at this point in the history
## What kind of change does this PR introduce?
* `FixLatestUnexpiredChallenge` should be scoped to the `factor_id` and
not all challenges in the table

## What is the current behavior?

Please link any relevant issues here.

## What is the new behavior?

Feel free to include screenshots if it includes visual changes.

## Additional context

Add any other context or screenshots.
  • Loading branch information
kangmingtay authored Aug 2, 2024
1 parent 81b332d commit ac14e82
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/models/factor.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func (f *Factor) FindLatestUnexpiredChallenge(tx *storage.Connection, expiryDura
var challenge Challenge
expirationTime := now.Add(time.Duration(expiryDuration) * time.Second)

err := tx.Where("sent_at > ?", expirationTime).
err := tx.Where("sent_at > ? and factor_id = ?", expirationTime, f.ID).
Order("sent_at desc").
First(&challenge)

Expand Down

0 comments on commit ac14e82

Please sign in to comment.