mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-13 07:29:02 +08:00
fix: app token's last_used_at can't be updated when last_used_at is null (#12770)
This commit is contained in:
parent
e09f6e4987
commit
05a0faff6a
@ -195,7 +195,11 @@ def validate_and_get_api_token(scope: str | None = None):
|
|||||||
with Session(db.engine, expire_on_commit=False) as session:
|
with Session(db.engine, expire_on_commit=False) as session:
|
||||||
update_stmt = (
|
update_stmt = (
|
||||||
update(ApiToken)
|
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)
|
.values(last_used_at=current_time)
|
||||||
.returning(ApiToken)
|
.returning(ApiToken)
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user