Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saml fix #3246

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions backend/ee/danswer/db/saml.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
from sqlalchemy import func
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm import selectinload
from sqlalchemy.orm import Session

from danswer.configs.app_configs import SESSION_EXPIRE_TIME_SECONDS
from danswer.db.models import SamlAccount
from danswer.db.models import User


def upsert_saml_account(
Expand Down Expand Up @@ -52,7 +52,7 @@ async def get_saml_account(
(which is necessarily async due to FastAPI Users)"""
stmt = (
select(SamlAccount)
.join(User, User.id == SamlAccount.user_id) # type: ignore
.options(selectinload(SamlAccount.user)) # Use selectinload for collections
.where(
and_(
SamlAccount.encrypted_cookie == cookie,
Expand All @@ -62,7 +62,7 @@ async def get_saml_account(
)

result = await async_db_session.execute(stmt)
return result.scalar_one_or_none()
return result.scalars().unique().one_or_none()


async def expire_saml_account(
Expand Down
Loading