Remove db.get_session.
This commit is contained in:
@@ -42,7 +42,7 @@ async def get_session(token: str, host: str | None = None) -> Session:
|
||||
host = hostutil.normalize_host(host)
|
||||
if not host:
|
||||
raise ValueError("Invalid host")
|
||||
session = db.get_session(token)
|
||||
session = db.data().sessions.get(token)
|
||||
if session:
|
||||
if session.host is None:
|
||||
# First time binding: store exact host:port (or IPv6 form) now.
|
||||
@@ -56,7 +56,7 @@ async def get_session(token: str, host: str | None = None) -> Session:
|
||||
|
||||
async def refresh_session_token(token: str, *, ip: str, user_agent: str):
|
||||
"""Refresh a session extending its expiry."""
|
||||
session_record = db.get_session(token)
|
||||
session_record = db.data().sessions.get(token)
|
||||
if not session_record:
|
||||
raise ValueError("Session not found or expired")
|
||||
updated = db.update_session(
|
||||
|
||||
@@ -55,7 +55,6 @@ from paskia.db.operations import (
|
||||
get_reset_token,
|
||||
get_role,
|
||||
get_roles_by_organization,
|
||||
get_session,
|
||||
get_session_context,
|
||||
get_user_by_uuid,
|
||||
get_user_organization,
|
||||
@@ -132,7 +131,6 @@ __all__ = [
|
||||
"get_reset_token",
|
||||
"get_role",
|
||||
"get_roles_by_organization",
|
||||
"get_session",
|
||||
"get_session_context",
|
||||
"get_user_by_uuid",
|
||||
"get_user_organization",
|
||||
|
||||
@@ -220,18 +220,6 @@ def get_credentials_by_user_uuid(user_uuid: UUID) -> list[Credential]:
|
||||
return [c for c in _db.credentials.values() if c.user == user_uuid]
|
||||
|
||||
|
||||
def get_session(key: str) -> Session | None:
|
||||
"""Get session by key.
|
||||
|
||||
Call sites:
|
||||
- Get session to delete it (admin.py:799)
|
||||
- Get session to validate token (authsession.py:45)
|
||||
- Get session to refresh it (authsession.py:59)
|
||||
- Get session to delete it in user API (user.py:94)
|
||||
"""
|
||||
return _db.sessions.get(key)
|
||||
|
||||
|
||||
def _reset_key(passphrase: str) -> bytes:
|
||||
"""Hash a passphrase to bytes for reset token storage."""
|
||||
if not _is_passphrase(passphrase):
|
||||
|
||||
@@ -823,7 +823,7 @@ async def admin_delete_user_session(
|
||||
status_code=403, detail="Insufficient permissions", mode="forbidden"
|
||||
)
|
||||
|
||||
target_session = db.get_session(session_id)
|
||||
target_session = db.data().sessions.get(session_id)
|
||||
if not target_session or target_session.user != user_uuid:
|
||||
raise HTTPException(status_code=404, detail="Session not found")
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ async def api_delete_session(
|
||||
status_code=401, detail="Session expired", mode="login"
|
||||
) from exc
|
||||
|
||||
target_session = db.get_session(session_id)
|
||||
target_session = db.data().sessions.get(session_id)
|
||||
if not target_session or target_session.user != current_session.user:
|
||||
raise HTTPException(status_code=404, detail="Session not found")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user