Skip to content

Commit

Permalink
functional
Browse files Browse the repository at this point in the history
  • Loading branch information
pablonyx committed Jan 15, 2025
1 parent d609d6a commit c1f07da
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions backend/onyx/auth/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
from httpx_oauth.oauth2 import BaseOAuth2
from httpx_oauth.oauth2 import OAuth2Token
from pydantic import BaseModel
from sqlalchemy import text
from sqlalchemy.ext.asyncio import AsyncSession

from onyx.auth.api_key import get_hashed_api_key_from_request
Expand Down Expand Up @@ -371,6 +372,8 @@ async def oauth_callback(

except exceptions.UserNotExists:
try:
# Set the search path for the current session
await db_session.execute(text(f'SET search_path = "{tenant_id}"'))
# Attempt to get user by email
user = await self.get_by_email(account_email)
if not associate_by_email:
Expand All @@ -395,7 +398,9 @@ async def oauth_callback(
# OAuth account creation happens in the correct tenant schema

# Add OAuth account
await db_session.execute(text(f'SET search_path = "{tenant_id}"'))
await self.user_db.add_oauth_account(user, oauth_account_dict)

await self.on_after_register(user, request)

else:
Expand Down

0 comments on commit c1f07da

Please sign in to comment.