Skip to content

Commit

Permalink
Saml fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Weves committed Nov 25, 2024
1 parent b625ee3 commit 076ce2e
Showing 1 changed file with 3 additions and 3 deletions.
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

0 comments on commit 076ce2e

Please sign in to comment.