Просмотр исходного кода

fix: app token's last_used_at can't be updated when last_used_at is null (#12770)

tags/0.15.2
EricPan 9 месяцев назад
Родитель
Сommit
05a0faff6a
Аккаунт пользователя с таким Email не найден
1 измененных файлов: 5 добавлений и 1 удалений
  1. 5
    1
      api/controllers/service_api/wraps.py

+ 5
- 1
api/controllers/service_api/wraps.py Просмотреть файл

@@ -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)
)

Загрузка…
Отмена
Сохранить