File tree Expand file tree Collapse file tree 3 files changed +42
-2
lines changed
supertokens_python/recipe/dashboard Expand file tree Collapse file tree 3 files changed +42
-2
lines changed Original file line number Diff line number Diff line change 1010 APIOptions ,
1111 UserGetAPINoUserFoundError ,
1212 UserGetAPIOkResponse ,
13+ UserGetAPIRecipeNotInitialisedError ,
1314)
14- from ...utils import is_valid_recipe_id
15+ from ...utils import is_recipe_initialised , is_valid_recipe_id
1516
1617
1718async def handle_user_get (
1819 _api_interface : APIInterface , api_options : APIOptions
19- ) -> Union [UserGetAPINoUserFoundError , UserGetAPIOkResponse ]:
20+ ) -> Union [
21+ UserGetAPINoUserFoundError ,
22+ UserGetAPIOkResponse ,
23+ UserGetAPIRecipeNotInitialisedError ,
24+ ]:
2025 user_id = api_options .request .get_query_param ("userId" )
2126 recipe_id = api_options .request .get_query_param ("recipeId" )
2227
@@ -29,6 +34,9 @@ async def handle_user_get(
2934 if not is_valid_recipe_id (recipe_id ):
3035 raise_bad_input_exception ("Invalid recipe id" )
3136
37+ if not is_recipe_initialised (recipe_id ):
38+ return UserGetAPIRecipeNotInitialisedError ()
39+
3240 user_response = await get_user_for_recipe_id (user_id , recipe_id )
3341 if user_response is None :
3442 return UserGetAPINoUserFoundError ()
Original file line number Diff line number Diff line change @@ -132,6 +132,13 @@ def to_json(self) -> Dict[str, Any]:
132132 return {"status" : self .status }
133133
134134
135+ class UserGetAPIRecipeNotInitialisedError (APIResponse ):
136+ status : str = "RECIPE_NOT_INITIALISED"
137+
138+ def to_json (self ) -> Dict [str , Any ]:
139+ return {"status" : self .status }
140+
141+
135142class FeatureNotEnabledError (APIResponse ):
136143 status : str = "FEATURE_NOT_ENABLED_ERROR"
137144
Original file line number Diff line number Diff line change @@ -324,3 +324,28 @@ async def update_user_dict(
324324 return GetUserForRecipeIdResult (user , recipe )
325325
326326 return None
327+
328+
329+ def is_recipe_initialised (recipeId : str ) -> bool :
330+ if recipeId == EmailPasswordRecipe .recipe_id :
331+ try :
332+ EmailPasswordRecipe .get_instance ()
333+ return True
334+ except Exception :
335+ return False
336+
337+ elif recipeId == PasswordlessRecipe .recipe_id :
338+ try :
339+ PasswordlessRecipe .get_instance ()
340+ return True
341+ except Exception :
342+ return False
343+
344+ elif recipeId == ThirdPartyRecipe .recipe_id :
345+ try :
346+ ThirdPartyRecipe .get_instance ()
347+ return True
348+ except Exception :
349+ return False
350+
351+ return False
You can’t perform that action at this time.
0 commit comments