Skip to content

Commit

Permalink
fix: app token's last_used_at can't be updated when last_used_at is n…
Browse files Browse the repository at this point in the history
…ull (#12770)
  • Loading branch information
Egfly authored Jan 22, 2025
1 parent e09f6e4 commit 05a0faf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion api/controllers/service_api/wraps.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,11 @@ def validate_and_get_api_token(scope: str | None = None):
with Session(db.engine, expire_on_commit=False) as session:
update_stmt = (
update(ApiToken)
.where(ApiToken.token == auth_token, ApiToken.last_used_at < cutoff_time, ApiToken.type == scope)
.where(
ApiToken.token == auth_token,
(ApiToken.last_used_at.is_(None) | (ApiToken.last_used_at < cutoff_time)),
ApiToken.type == scope,
)
.values(last_used_at=current_time)
.returning(ApiToken)
)
Expand Down

0 comments on commit 05a0faf

Please sign in to comment.