Skip to content

Commit

Permalink
fix: app token's last_used_at can't be updated when last_used_at is null
Browse files Browse the repository at this point in the history
  • Loading branch information
Egfly committed Jan 15, 2025
1 parent bc3a570 commit 6f20275
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion api/controllers/service_api/wraps.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ 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 6f20275

Please sign in to comment.