fix: use BYPASSRLS session for all auth deps and user-mutation endpoints
Phase 4 enabled RLS on the users table. All code paths that touch users (or other RLS-protected tables) before require_tenant_context sets app.current_account_id must use get_admin_db (BYPASSRLS): - deps.py: get_current_user and get_current_active_user → get_admin_db - auth.py: all endpoints → get_admin_db (login, register, refresh, etc. run before tenant context exists; mutation endpoints also need session consistency since current_user is in the admin session) - accounts.py: transfer_ownership, leave_account, delete_account → get_admin_db (these mutate current_user directly) - onboarding.py: dismiss_onboarding → get_admin_db (same reason) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.api.deps import get_current_active_user
|
||||
from app.core.database import get_db
|
||||
from app.core.admin_database import get_admin_db
|
||||
from app.models.assistant_chat import AssistantChat
|
||||
from app.models.psa_connection import PsaConnection
|
||||
from app.models.session import Session
|
||||
@@ -98,7 +99,7 @@ async def get_onboarding_status(
|
||||
|
||||
@router.post("/onboarding-status/dismiss", response_model=OnboardingStatus)
|
||||
async def dismiss_onboarding(
|
||||
db: Annotated[AsyncSession, Depends(get_db)],
|
||||
db: Annotated[AsyncSession, Depends(get_admin_db)],
|
||||
current_user: Annotated[User, Depends(get_current_active_user)],
|
||||
) -> OnboardingStatus:
|
||||
"""Dismiss the onboarding checklist for the current user."""
|
||||
|
||||
Reference in New Issue
Block a user