File tree Expand file tree Collapse file tree 5 files changed +30
-10
lines changed Expand file tree Collapse file tree 5 files changed +30
-10
lines changed Original file line number Diff line number Diff line change 7
7
from sqlalchemy .orm import aliased
8
8
from sqlalchemy .orm import Session
9
9
10
+ from onyx .auth .users import anonymous_user_enabled
10
11
from onyx .configs .app_configs import DISABLE_AUTH
11
12
from onyx .configs .constants import TokenRateLimitScope
12
13
from onyx .db .models import TokenRateLimit
@@ -51,8 +52,11 @@ def _add_user_filters(
51
52
52
53
# If user is None, this is an anonymous user and we should only show public token_rate_limits
53
54
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" )
56
60
57
61
where_clause = User__UG .user_id == user .id
58
62
if user .role == UserRole .CURATOR and get_editable :
Original file line number Diff line number Diff line change 10
10
from sqlalchemy .orm import joinedload
11
11
from sqlalchemy .orm import Session
12
12
13
+ from onyx .auth .users import anonymous_user_enabled
13
14
from onyx .configs .app_configs import DISABLE_AUTH
14
15
from onyx .configs .constants import DocumentSource
15
16
from onyx .db .connector import fetch_connector_by_id
@@ -66,8 +67,11 @@ def _add_user_filters(
66
67
67
68
# If user is None, this is an anonymous user and we should only show public cc_pairs
68
69
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" )
71
75
72
76
where_clause = User__UG .user_id == user .id
73
77
if user .role == UserRole .CURATOR and get_editable :
Original file line number Diff line number Diff line change 12
12
from sqlalchemy .orm import aliased
13
13
from sqlalchemy .orm import Session
14
14
15
+ from onyx .auth .users import anonymous_user_enabled
15
16
from onyx .configs .app_configs import DISABLE_AUTH
16
17
from onyx .db .connector_credential_pair import get_cc_pair_groups_for_ids
17
18
from onyx .db .connector_credential_pair import get_connector_credential_pairs
@@ -65,8 +66,11 @@ def _add_user_filters(
65
66
66
67
# If user is None, this is an anonymous user and we should only show public DocumentSets
67
68
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" )
70
74
71
75
where_clause = User__UserGroup .user_id == user .id
72
76
if user .role == UserRole .CURATOR and get_editable :
Original file line number Diff line number Diff line change 13
13
from sqlalchemy .orm import aliased
14
14
from sqlalchemy .orm import Session
15
15
16
+ from onyx .auth .users import anonymous_user_enabled
16
17
from onyx .configs .app_configs import DISABLE_AUTH
17
18
from onyx .configs .constants import MessageType
18
19
from onyx .configs .constants import SearchFeedbackType
@@ -88,8 +89,11 @@ def _add_user_filters(
88
89
89
90
# If user is None, this is an anonymous user and we should only show public documents
90
91
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" )
93
97
94
98
where_clause = User__UG .user_id == user .id
95
99
if user .role == UserRole .CURATOR and get_editable :
Original file line number Diff line number Diff line change 17
17
from sqlalchemy .orm import Session
18
18
19
19
from onyx .auth .schemas import UserRole
20
+ from onyx .auth .users import anonymous_user_enabled
20
21
from onyx .configs .app_configs import DISABLE_AUTH
21
22
from onyx .configs .chat_configs import BING_API_KEY
22
23
from onyx .configs .chat_configs import CONTEXT_CHUNKS_ABOVE
@@ -82,8 +83,11 @@ def _add_user_filters(
82
83
83
84
# If user is None, this is an anonymous user and we should only show public Personas
84
85
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" )
87
91
88
92
where_clause = User__UserGroup .user_id == user .id
89
93
if user .role == UserRole .CURATOR and get_editable :
You can’t perform that action at this time.
0 commit comments