Skip to content

Commit 47bcc05

Browse files
committed
quick nit
1 parent 46c3ab4 commit 47bcc05

File tree

5 files changed

+30
-10
lines changed

5 files changed

+30
-10
lines changed

backend/ee/onyx/db/token_limit.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from sqlalchemy.orm import aliased
88
from sqlalchemy.orm import Session
99

10+
from onyx.auth.users import anonymous_user_enabled
1011
from onyx.configs.app_configs import DISABLE_AUTH
1112
from onyx.configs.constants import TokenRateLimitScope
1213
from onyx.db.models import TokenRateLimit
@@ -51,8 +52,11 @@ def _add_user_filters(
5152

5253
# If user is None, this is an anonymous user and we should only show public token_rate_limits
5354
if user is None:
54-
where_clause = TokenRateLimit.scope == TokenRateLimitScope.GLOBAL
55-
return stmt.where(where_clause)
55+
if anonymous_user_enabled():
56+
where_clause = TokenRateLimit.scope == TokenRateLimitScope.GLOBAL
57+
return stmt.where(where_clause)
58+
else:
59+
raise ValueError("User not authenticated")
5660

5761
where_clause = User__UG.user_id == user.id
5862
if user.role == UserRole.CURATOR and get_editable:

backend/onyx/db/connector_credential_pair.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from sqlalchemy.orm import joinedload
1111
from sqlalchemy.orm import Session
1212

13+
from onyx.auth.users import anonymous_user_enabled
1314
from onyx.configs.app_configs import DISABLE_AUTH
1415
from onyx.configs.constants import DocumentSource
1516
from onyx.db.connector import fetch_connector_by_id
@@ -66,8 +67,11 @@ def _add_user_filters(
6667

6768
# If user is None, this is an anonymous user and we should only show public cc_pairs
6869
if user is None:
69-
where_clause = ConnectorCredentialPair.access_type == AccessType.PUBLIC
70-
return stmt.where(where_clause)
70+
if anonymous_user_enabled():
71+
where_clause = ConnectorCredentialPair.access_type == AccessType.PUBLIC
72+
return stmt.where(where_clause)
73+
else:
74+
raise ValueError("User not authenticated")
7175

7276
where_clause = User__UG.user_id == user.id
7377
if user.role == UserRole.CURATOR and get_editable:

backend/onyx/db/document_set.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from sqlalchemy.orm import aliased
1313
from sqlalchemy.orm import Session
1414

15+
from onyx.auth.users import anonymous_user_enabled
1516
from onyx.configs.app_configs import DISABLE_AUTH
1617
from onyx.db.connector_credential_pair import get_cc_pair_groups_for_ids
1718
from onyx.db.connector_credential_pair import get_connector_credential_pairs
@@ -65,8 +66,11 @@ def _add_user_filters(
6566

6667
# If user is None, this is an anonymous user and we should only show public DocumentSets
6768
if user is None:
68-
where_clause = DocumentSetDBModel.is_public == True # noqa: E712
69-
return stmt.where(where_clause)
69+
if anonymous_user_enabled():
70+
where_clause = DocumentSetDBModel.is_public == True # noqa: E712
71+
return stmt.where(where_clause)
72+
else:
73+
raise ValueError("User not authenticated")
7074

7175
where_clause = User__UserGroup.user_id == user.id
7276
if user.role == UserRole.CURATOR and get_editable:

backend/onyx/db/feedback.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from sqlalchemy.orm import aliased
1414
from sqlalchemy.orm import Session
1515

16+
from onyx.auth.users import anonymous_user_enabled
1617
from onyx.configs.app_configs import DISABLE_AUTH
1718
from onyx.configs.constants import MessageType
1819
from onyx.configs.constants import SearchFeedbackType
@@ -88,8 +89,11 @@ def _add_user_filters(
8889

8990
# If user is None, this is an anonymous user and we should only show public documents
9091
if user is None:
91-
where_clause = CCPair.access_type == AccessType.PUBLIC
92-
return stmt.where(where_clause)
92+
if anonymous_user_enabled():
93+
where_clause = CCPair.access_type == AccessType.PUBLIC
94+
return stmt.where(where_clause)
95+
else:
96+
raise ValueError("User not authenticated")
9397

9498
where_clause = User__UG.user_id == user.id
9599
if user.role == UserRole.CURATOR and get_editable:

backend/onyx/db/persona.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from sqlalchemy.orm import Session
1818

1919
from onyx.auth.schemas import UserRole
20+
from onyx.auth.users import anonymous_user_enabled
2021
from onyx.configs.app_configs import DISABLE_AUTH
2122
from onyx.configs.chat_configs import BING_API_KEY
2223
from onyx.configs.chat_configs import CONTEXT_CHUNKS_ABOVE
@@ -82,8 +83,11 @@ def _add_user_filters(
8283

8384
# If user is None, this is an anonymous user and we should only show public Personas
8485
if user is None:
85-
where_clause = Persona.is_public == True # noqa: E712
86-
return stmt.where(where_clause)
86+
if anonymous_user_enabled():
87+
where_clause = Persona.is_public == True # noqa: E712
88+
return stmt.where(where_clause)
89+
else:
90+
raise ValueError("User not authenticated")
8791

8892
where_clause = User__UserGroup.user_id == user.id
8993
if user.role == UserRole.CURATOR and get_editable:

0 commit comments

Comments
 (0)