Skip to content

Commit b8fd8d0

Browse files
committed
makes type simpler
1 parent f6cf304 commit b8fd8d0

File tree

3 files changed

+5
-24
lines changed

3 files changed

+5
-24
lines changed

supertokens_python/recipe/multifactorauth/recipe_implementation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ async def get_mfa_requirements_for_auth(
147147
all_factors.add(factor)
148148
for factor in await required_secondary_factors_for_tenant():
149149
all_factors.add(factor)
150-
return MFARequirementList({"oneOf": list(all_factors)})
150+
return [{"oneOf": list(all_factors)}]
151151

152152
async def assert_allowed_to_setup_factor_else_throw_invalid_claim_error(
153153
self,

supertokens_python/recipe/multifactorauth/types.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,9 @@
2222
from .interfaces import RecipeInterface, APIInterface
2323

2424

25-
class MFARequirementList(List[Union[Dict[str, List[str]], str]]):
26-
def __init__(
27-
self,
28-
*args: Union[
29-
str, Dict[Union[Literal["oneOf"], Literal["allOfInAnyOrder"]], List[str]]
30-
],
31-
):
32-
super().__init__()
33-
for arg in args:
34-
if isinstance(arg, str):
35-
self.append(arg)
36-
else:
37-
if "oneOf" in arg:
38-
self.append({"oneOf": arg["oneOf"]})
39-
elif "allOfInAnyOrder" in arg:
40-
self.append({"allOfInAnyOrder": arg["allOfInAnyOrder"]})
41-
else:
42-
raise ValueError("Invalid dictionary format")
25+
MFARequirementList = List[
26+
Union[str, Dict[Union[Literal["oneOf"], Literal["allOfInAnyOrder"]], List[str]]]
27+
]
4328

4429

4530
class MFAClaimValue:

tests/test-server/test_functions_mapper.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,7 @@ async def get_mfa_requirements_for_auth(
135135
required_secondary_factors_for_tenant: Any,
136136
user_context: Dict[str, Any],
137137
) -> MFARequirementList:
138-
return (
139-
MFARequirementList("otp-phone")
140-
if user_context.get("requireFactor")
141-
else MFARequirementList()
142-
)
138+
return ["otp-phone"] if user_context.get("requireFactor") else []
143139

144140
original_implementation.get_mfa_requirements_for_auth = (
145141
get_mfa_requirements_for_auth

0 commit comments

Comments
 (0)