Remove list_sessions_for_user, inline db access at call sites.
This commit is contained in:
@@ -62,7 +62,6 @@ from paskia.db.operations import (
|
||||
init,
|
||||
list_organizations,
|
||||
list_permissions,
|
||||
list_sessions_for_user,
|
||||
login,
|
||||
remove_permission_from_organization,
|
||||
remove_permission_from_role,
|
||||
@@ -139,7 +138,7 @@ __all__ = [
|
||||
"get_user_organization",
|
||||
"list_organizations",
|
||||
"list_permissions",
|
||||
"list_sessions_for_user",
|
||||
"list_permissions",
|
||||
# Write ops
|
||||
"add_permission_to_organization",
|
||||
"add_permission_to_role",
|
||||
|
||||
@@ -232,16 +232,6 @@ def get_session(key: str) -> Session | None:
|
||||
return _db.sessions.get(key)
|
||||
|
||||
|
||||
def list_sessions_for_user(user_uuid: UUID) -> list[Session]:
|
||||
"""Get all active sessions for a user.
|
||||
|
||||
Call sites:
|
||||
- List sessions for user info (userinfo.py:75)
|
||||
- List sessions for user details API (admin.py:651)
|
||||
"""
|
||||
return [s for s in _db.sessions.values() if s.user == user_uuid]
|
||||
|
||||
|
||||
def _reset_key(passphrase: str) -> bytes:
|
||||
"""Hash a passphrase to bytes for reset token storage."""
|
||||
if not _is_passphrase(passphrase):
|
||||
|
||||
@@ -675,7 +675,7 @@ async def admin_get_user_detail(
|
||||
|
||||
# Get sessions for the user
|
||||
normalized_request_host = hostutil.normalize_host(request.headers.get("host"))
|
||||
session_records = db.list_sessions_for_user(user_uuid)
|
||||
session_records = [s for s in db.data().sessions.values() if s.user == user_uuid]
|
||||
current_session_key = auth
|
||||
sessions_payload: list[dict] = []
|
||||
for entry in session_records:
|
||||
|
||||
@@ -72,7 +72,7 @@ async def format_user_info(
|
||||
|
||||
# Format sessions
|
||||
normalized_request_host = hostutil.normalize_host(request_host)
|
||||
session_records = db.list_sessions_for_user(user_uuid)
|
||||
session_records = [s for s in db.data().sessions.values() if s.user == user_uuid]
|
||||
current_session_key = auth
|
||||
sessions_payload: list[dict] = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user