diff --git a/CTFd/api/v1/hints.py b/CTFd/api/v1/hints.py index 10d39f91..0ee60fa3 100644 --- a/CTFd/api/v1/hints.py +++ b/CTFd/api/v1/hints.py @@ -125,7 +125,14 @@ class Hint(Resource): # Get the IDs of all hints that the user has unlocked all_unlocks = HintUnlocks.query.filter_by(account_id=user.account_id).all() - unlock_ids = {unlock.id for unlock in all_unlocks} + unlock_ids = {unlock.target for unlock in all_unlocks} + + # Get the IDs of all free hints + free_hints = Hints.query.filter_by(cost=0).all() + free_ids = {h.id for h in free_hints} + + # Add free hints to unlocked IDs + unlock_ids.update(free_ids) # Filter out hint IDs that don't exist all_hint_ids = {h.id for h in Hints.query.with_entities(Hints.id).all()}