Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabhpoddar committed Oct 1, 2024
1 parent 61cfea3 commit 520a30b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
6 changes: 1 addition & 5 deletions supertokens_python/recipe/multifactorauth/syncio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
from supertokens_python.recipe.session import SessionContainer
from supertokens_python.async_to_sync_wrapper import sync

from ..interfaces import (
MFARequirementList,
)


def assert_allowed_to_setup_factor_else_throw_invalid_claim_error(
session: SessionContainer,
Expand All @@ -42,7 +38,7 @@ def assert_allowed_to_setup_factor_else_throw_invalid_claim_error(
def get_mfa_requirements_for_auth(
session: SessionContainer,
user_context: Optional[Dict[str, Any]] = None,
) -> MFARequirementList:
):
if user_context is None:
user_context = {}

Expand Down
17 changes: 17 additions & 0 deletions tests/auth-react/flask-server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
ResyncSessionAndFetchMFAInfoPUTOkResult,
)
from supertokens_python.recipe.multifactorauth.recipe import MultiFactorAuthRecipe
from supertokens_python.recipe.multifactorauth.syncio import (
add_to_required_secondary_factors_for_user,
)
from supertokens_python.recipe.multifactorauth.types import MFARequirementList
from supertokens_python.recipe.multitenancy.interfaces import (
AssociateUserToTenantEmailAlreadyExistsError,
Expand Down Expand Up @@ -1331,6 +1334,20 @@ def set_mfa_info():
return jsonify({"status": "OK"})


@app.route("/addRequiredFactor", methods=["POST"]) # type: ignore
@verify_session()
def add_required_factor():
session_: SessionContainer = g.supertokens # type: ignore

body = request.get_json()
if body is None or "factorId" not in body:
return jsonify({"error": "Invalid request body"}), 400

add_to_required_secondary_factors_for_user(session_.get_user_id(), body["factorId"])

return jsonify({"status": "OK"})


@app.route("/test/setEnabledRecipes", methods=["POST"]) # type: ignore
def test_set_enabled_recipes():
global enabled_recipes
Expand Down

0 comments on commit 520a30b

Please sign in to comment.