Backport PR #3910: use equality to filter token prefixes

This commit is contained in:
Yuvi Panda
2022-06-01 19:05:45 +05:30
committed by MeeseeksDev[bot]
parent fe64595d75
commit 9f23bc2959

View File

@@ -536,9 +536,7 @@ class Hashed(Expiring):
prefix = token[: cls.prefix_length]
# since we can't filter on hashed values, filter on prefix
# so we aren't comparing with all tokens
prefix_match = db.query(cls).filter(
bindparam('prefix', prefix).startswith(cls.prefix)
)
prefix_match = db.query(cls).filter_by(prefix=prefix)
prefix_match = prefix_match.filter(
or_(cls.expires_at == None, cls.expires_at >= cls.now())
)