Compare commits

...

2 Commits

Author SHA1 Message Date
pablodanswer
c1f07da4c8 functional 2025-01-15 10:10:11 -08:00
pablodanswer
d609d6a7a3 admin usage for seeding 2025-01-15 09:54:36 -08:00
3 changed files with 22 additions and 6 deletions

View File

@@ -46,6 +46,7 @@ from httpx_oauth.integrations.fastapi import OAuth2AuthorizeCallback
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
@@ -371,6 +372,8 @@ class UserManager(UUIDIDMixin, BaseUserManager[User, uuid.UUID]):
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:
@@ -395,7 +398,9 @@ class UserManager(UUIDIDMixin, BaseUserManager[User, uuid.UUID]):
# 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:

View File

@@ -12,6 +12,7 @@ from sqlalchemy.orm import Session
from onyx.configs.app_configs import DISABLE_AUTH
from onyx.db.connector import fetch_connector_by_id
from onyx.db.credentials import fetch_credential_by_id
from onyx.db.credentials import fetch_credential_by_id_for_user
from onyx.db.enums import AccessType
from onyx.db.enums import ConnectorCredentialPairStatus
@@ -388,14 +389,23 @@ def add_credential_to_connector(
auto_sync_options: dict | None = None,
initial_status: ConnectorCredentialPairStatus = ConnectorCredentialPairStatus.ACTIVE,
last_successful_index_time: datetime | None = None,
seeding_flow: bool = False,
) -> StatusResponse:
connector = fetch_connector_by_id(connector_id, db_session)
credential = fetch_credential_by_id_for_user(
credential_id,
user,
db_session,
get_editable=False,
)
# If we are in the seeding flow, we shouldn't need to check if the credential belongs to the user
if seeding_flow:
credential = fetch_credential_by_id(
db_session=db_session,
credential_id=credential_id,
)
else:
credential = fetch_credential_by_id_for_user(
credential_id,
user,
db_session,
get_editable=False,
)
if connector is None:
raise HTTPException(status_code=404, detail="Connector does not exist")

View File

@@ -189,6 +189,7 @@ def seed_initial_documents(
groups=None,
initial_status=ConnectorCredentialPairStatus.PAUSED,
last_successful_index_time=last_index_time,
seeding_flow=True,
)
cc_pair_id = cast(int, result.data)
processed_docs = fetch_versioned_implementation(