작업 내용 저장
This commit is contained in:
@@ -564,6 +564,26 @@ class PostgresPortfolioRepository:
|
||||
rows = cur.fetchall()
|
||||
return [self._row_to_auth_token(row) for row in rows]
|
||||
|
||||
def list_service_tokens(
|
||||
self,
|
||||
user_id: str | None = None,
|
||||
*,
|
||||
include_revoked: bool = False,
|
||||
) -> list[AuthToken]:
|
||||
self.ensure_schema()
|
||||
conditions = ["token_type = 'service'"]
|
||||
params: list = []
|
||||
if user_id is not None:
|
||||
conditions.append("user_id = %s")
|
||||
params.append(user_id)
|
||||
if not include_revoked:
|
||||
conditions.append("revoked_at IS NULL")
|
||||
where = "WHERE " + " AND ".join(conditions) + " "
|
||||
with self._connect().cursor() as cur:
|
||||
cur.execute(_SELECT_AUTH_TOKEN + where + "ORDER BY created_at DESC, id ASC", params)
|
||||
rows = cur.fetchall()
|
||||
return [self._row_to_auth_token(row) for row in rows]
|
||||
|
||||
def revoke_auth_token(self, user_id: str, token_id: str) -> None:
|
||||
self.ensure_schema()
|
||||
with self._connect().cursor() as cur:
|
||||
|
||||
Reference in New Issue
Block a user