Skip to content

Commit e0995f0

Browse files
committed
fixes stuff
1 parent 8e3a7b2 commit e0995f0

File tree

11 files changed

+623
-49
lines changed

11 files changed

+623
-49
lines changed

.pylintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ disable=raw-checker-failed,
123123
consider-using-in,
124124
no-else-return,
125125
no-self-use,
126-
no-else-raise
126+
no-else-raise,
127+
too-many-nested-blocks,
127128

128129

129130
# Enable the message, report, category or checker with the given id(s). You can

.vscode/launch.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@
1515
"FLASK_DEBUG": "1"
1616
},
1717
"jinja": true
18+
},
19+
{
20+
"name": "Python: Flask, supertokens-auth-react tests",
21+
"type": "python",
22+
"request": "launch",
23+
"program": "${workspaceFolder}/tests/auth-react/flask-server/app.py",
24+
"args": [
25+
"--port",
26+
"8083"
27+
],
28+
"cwd": "${workspaceFolder}/tests/auth-react/flask-server",
29+
"env": {
30+
"FLASK_DEBUG": "1"
31+
},
32+
"jinja": true
1833
}
1934
]
2035
}

supertokens_python/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from typing_extensions import Literal
1818

1919
from supertokens_python.framework.request import BaseRequest
20+
from supertokens_python.types import RecipeUserId
2021

2122
from . import supertokens
2223
from .recipe_module import RecipeModule
@@ -49,3 +50,7 @@ def get_request_from_user_context(
4950
user_context: Optional[Dict[str, Any]],
5051
) -> Optional[BaseRequest]:
5152
return Supertokens.get_instance().get_request_from_user_context(user_context)
53+
54+
55+
def convert_to_recipe_user_id(user_id: str) -> RecipeUserId:
56+
return RecipeUserId(user_id)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved.
2+
#
3+
# This software is licensed under the Apache License, Version 2.0 (the
4+
# "License") as published by the Apache Software Foundation.
5+
#
6+
# You may not use this file except in compliance with the License. You may
7+
# obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
# License for the specific language governing permissions and limitations
13+
# under the License.
14+
from __future__ import annotations
15+
16+
from typing import TYPE_CHECKING, Callable, List, Optional, Union
17+
18+
from supertokens_python.recipe.multifactorauth.types import OverrideConfig
19+
20+
from .recipe import MultiFactorAuthRecipe
21+
22+
if TYPE_CHECKING:
23+
from supertokens_python.supertokens import AppInfo
24+
25+
from ...recipe_module import RecipeModule
26+
27+
28+
def init(
29+
first_factors: Optional[List[str]] = None,
30+
override: Union[OverrideConfig, None] = None,
31+
) -> Callable[[AppInfo], RecipeModule]:
32+
return MultiFactorAuthRecipe.init(
33+
first_factors,
34+
override,
35+
)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved.
2+
#
3+
# This software is licensed under the Apache License, Version 2.0 (the
4+
# "License") as published by the Apache Software Foundation.
5+
#
6+
# You may not use this file except in compliance with the License. You may
7+
# obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
# License for the specific language governing permissions and limitations
13+
# under the License.
14+
from __future__ import annotations
15+
16+
from typing import TYPE_CHECKING, Callable, Union
17+
18+
from supertokens_python.recipe.totp.types import TOTPConfig
19+
20+
from .recipe import TOTPRecipe
21+
22+
if TYPE_CHECKING:
23+
from supertokens_python.supertokens import AppInfo
24+
25+
from ...recipe_module import RecipeModule
26+
27+
28+
def init(
29+
config: Union[TOTPConfig, None] = None,
30+
) -> Callable[[AppInfo], RecipeModule]:
31+
return TOTPRecipe.init(
32+
config=config,
33+
)

supertokens_python/supertokens.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,6 @@ def __init__(
255255
"Please provide at least one recipe to the supertokens.init function call"
256256
)
257257

258-
from supertokens_python.recipe.multifactorauth.recipe import (
259-
MultiFactorAuthRecipe,
260-
)
261-
from supertokens_python.recipe.totp.recipe import TOTPRecipe
262-
263258
multitenancy_found = False
264259
totp_found = False
265260
user_metadata_found = False
@@ -272,9 +267,9 @@ def make_recipe(recipe: Callable[[AppInfo], RecipeModule]) -> RecipeModule:
272267
multitenancy_found = True
273268
elif recipe_module.get_recipe_id() == "usermetadata":
274269
user_metadata_found = True
275-
elif recipe_module.get_recipe_id() == MultiFactorAuthRecipe.recipe_id:
270+
elif recipe_module.get_recipe_id() == "multifactorauth":
276271
multi_factor_auth_found = True
277-
elif recipe_module.get_recipe_id() == TOTPRecipe.recipe_id:
272+
elif recipe_module.get_recipe_id() == "totp":
278273
totp_found = True
279274
return recipe_module
280275

0 commit comments

Comments
 (0)