2929from .interfaces import (
3030 APIInterface ,
3131 APIOptions ,
32- TypeGetTenantIdForUserId ,
3332 TypeGetAllowedDomainsForTenantId ,
34- TenantIdOkResult ,
35- UnknownUserIdError ,
3633)
3734
3835from .recipe_implementation import RecipeImplementation
@@ -78,7 +75,6 @@ def __init__(
7875 self ,
7976 recipe_id : str ,
8077 app_info : AppInfo ,
81- get_tenant_id_for_user_id : Optional [TypeGetTenantIdForUserId ] = None ,
8278 get_allowed_domains_for_tenant_id : Optional [
8379 TypeGetAllowedDomainsForTenantId
8480 ] = None ,
@@ -87,7 +83,6 @@ def __init__(
8783 ) -> None :
8884 super ().__init__ (recipe_id , app_info )
8985 self .config = validate_and_normalise_user_input (
90- get_tenant_id_for_user_id ,
9186 get_allowed_domains_for_tenant_id ,
9287 error_handlers ,
9388 override ,
@@ -109,10 +104,6 @@ def __init__(
109104 else self .config .override .apis (api_implementation )
110105 )
111106
112- self .get_tenant_id_for_user_id_funcs_from_other_recipes : List [
113- TypeGetTenantIdForUserId
114- ] = []
115-
116107 self .static_third_party_providers : List [ProviderInput ] = []
117108
118109 def is_error_from_this_recipe_based_on_instance (self , err : Exception ) -> bool :
@@ -169,7 +160,6 @@ def get_all_cors_headers(self) -> List[str]:
169160
170161 @staticmethod
171162 def init (
172- get_tenant_id_for_user_id : Union [TypeGetTenantIdForUserId , None ] = None ,
173163 get_allowed_domains_for_tenant_id : Union [
174164 TypeGetAllowedDomainsForTenantId , None
175165 ] = None ,
@@ -181,7 +171,6 @@ def func(app_info: AppInfo):
181171 MultitenancyRecipe .__instance = MultitenancyRecipe (
182172 MultitenancyRecipe .recipe_id ,
183173 app_info ,
184- get_tenant_id_for_user_id ,
185174 get_allowed_domains_for_tenant_id ,
186175 error_handlers ,
187176 override ,
@@ -219,24 +208,6 @@ def reset():
219208 raise_general_exception ("calling testing function in non testing env" )
220209 MultitenancyRecipe .__instance = None
221210
222- async def get_tenant_id_for_user_id (
223- self , user_id : str , user_context : Dict [str , Any ]
224- ) -> Union [TenantIdOkResult , UnknownUserIdError ]:
225- if self .config .get_tenant_id_for_user_id is not None :
226- res = await self .config .get_tenant_id_for_user_id (user_id , user_context )
227- if not isinstance (res , UnknownUserIdError ):
228- return res
229-
230- for f in self .get_tenant_id_for_user_id_funcs_from_other_recipes :
231- res = await f (user_id , user_context )
232- if not isinstance (res , UnknownUserIdError ):
233- return res
234-
235- return UnknownUserIdError ()
236-
237- def add_get_tenant_id_for_user_id_func (self , f : TypeGetTenantIdForUserId ):
238- self .get_tenant_id_for_user_id_funcs_from_other_recipes .append (f )
239-
240211
241212class APIImplementation (APIInterface ):
242213 async def login_methods_get (
@@ -286,23 +257,19 @@ class AllowedDomainsClaimClass(PrimitiveArrayClaim[List[str]]):
286257 def __init__ (self ):
287258 async def fetch_value (user_id : str , user_context : Dict [str , Any ]) -> List [str ]:
288259 recipe = MultitenancyRecipe .get_instance ()
289- tenant_ids_res = await recipe . get_tenant_id_for_user_id (
290- user_id , user_context
260+ tenant_id = (
261+ None # TODO fetch value will be passed with tenant_id as well later
291262 )
292263
293- if isinstance (tenant_ids_res , TenantIdOkResult ):
294- for tenant_id in tenant_ids_res .tenant_id :
295- if recipe .config .get_allowed_domains_for_tenant_id is None :
296- return (
297- []
298- ) # User did not provide a function to get allowed domains, but is using a validator. So we don't allow any domains by default
299-
300- domains_res = await recipe .config .get_allowed_domains_for_tenant_id (
301- tenant_id , user_context
302- )
303- return domains_res
264+ if recipe .config .get_allowed_domains_for_tenant_id is None :
265+ return (
266+ []
267+ ) # User did not provide a function to get allowed domains, but is using a validator. So we don't allow any domains by default
304268
305- raise Exception ("UNKNOWN_USER_ID" )
269+ domains_res = await recipe .config .get_allowed_domains_for_tenant_id (
270+ tenant_id , user_context
271+ )
272+ return domains_res
306273
307274 super ().__init__ (
308275 key = "st-tenant-domains" ,
0 commit comments