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 10
10
APIOptions ,
11
11
UserGetAPINoUserFoundError ,
12
12
UserGetAPIOkResponse ,
13
+ UserGetAPIRecipeNotInitialisedError ,
13
14
)
14
- from ...utils import is_valid_recipe_id
15
+ from ...utils import is_recipe_initialised , is_valid_recipe_id
15
16
16
17
17
18
async def handle_user_get (
18
19
_api_interface : APIInterface , api_options : APIOptions
19
- ) -> Union [UserGetAPINoUserFoundError , UserGetAPIOkResponse ]:
20
+ ) -> Union [
21
+ UserGetAPINoUserFoundError ,
22
+ UserGetAPIOkResponse ,
23
+ UserGetAPIRecipeNotInitialisedError ,
24
+ ]:
20
25
user_id = api_options .request .get_query_param ("userId" )
21
26
recipe_id = api_options .request .get_query_param ("recipeId" )
22
27
@@ -29,6 +34,9 @@ async def handle_user_get(
29
34
if not is_valid_recipe_id (recipe_id ):
30
35
raise_bad_input_exception ("Invalid recipe id" )
31
36
37
+ if not is_recipe_initialised (recipe_id ):
38
+ return UserGetAPIRecipeNotInitialisedError ()
39
+
32
40
user_response = await get_user_for_recipe_id (user_id , recipe_id )
33
41
if user_response is None :
34
42
return UserGetAPINoUserFoundError ()
Original file line number Diff line number Diff line change @@ -132,6 +132,13 @@ def to_json(self) -> Dict[str, Any]:
132
132
return {"status" : self .status }
133
133
134
134
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
+
135
142
class FeatureNotEnabledError (APIResponse ):
136
143
status : str = "FEATURE_NOT_ENABLED_ERROR"
137
144
Original file line number Diff line number Diff line change @@ -324,3 +324,28 @@ async def update_user_dict(
324
324
return GetUserForRecipeIdResult (user , recipe )
325
325
326
326
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