File tree Expand file tree Collapse file tree 2 files changed +12
-7
lines changed
supertokens_python/recipe/dashboard Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -69,19 +69,24 @@ async def should_allow_access(
69
69
70
70
admins = config .admins
71
71
72
- # If the user has provided no admins, allow
73
- if len (admins ) == 0 :
72
+ if admins is None :
74
73
return True
75
74
76
- email_in_headers = request .get_header ("email" )
75
+ if len (admins ) == 0 :
76
+ log_debug_message (
77
+ "User Dashboard: Throwing OPERATION_NOT_ALLOWED because user is not an admin"
78
+ )
79
+ raise DashboardOperationNotAllowedError ()
80
+
81
+ user_email = session_verification_response .get ("email" )
77
82
78
- if email_in_headers is None :
83
+ if user_email is None or not isinstance ( user_email , str ) :
79
84
log_debug_message (
80
85
"User Dashboard: Returning UNAUTHORISED_ERROR because no email was provided in headers"
81
86
)
82
87
return False
83
88
84
- if email_in_headers not in admins :
89
+ if user_email not in admins :
85
90
log_debug_message (
86
91
"User Dashboard: Throwing OPERATION_NOT_ALLOWED because user is not an admin"
87
92
)
Original file line number Diff line number Diff line change @@ -183,7 +183,7 @@ class DashboardConfig:
183
183
def __init__ (
184
184
self ,
185
185
api_key : Optional [str ],
186
- admins : List [str ],
186
+ admins : Optional [ List [str ] ],
187
187
override : OverrideConfig ,
188
188
auth_mode : str ,
189
189
):
@@ -208,7 +208,7 @@ def validate_and_normalise_user_input(
208
208
"User Dashboard: Providing 'admins' has no effect when using an api key."
209
209
)
210
210
211
- admins = [normalise_email (a ) for a in admins ] if admins is not None else []
211
+ admins = [normalise_email (a ) for a in admins ] if admins is not None else None
212
212
213
213
return DashboardConfig (
214
214
api_key ,
You can’t perform that action at this time.
0 commit comments