|
17 | 17 | from dotenv import load_dotenv |
18 | 18 | from flask import Flask, g, jsonify, make_response, request |
19 | 19 | from flask_cors import CORS |
20 | | - |
21 | 20 | from supertokens_python import ( |
22 | 21 | InputAppInfo, |
23 | 22 | Supertokens, |
|
50 | 49 | User, |
51 | 50 | ) |
52 | 51 | from supertokens_python.recipe.emailverification import ( |
53 | | - EmailVerificationRecipe, |
54 | 52 | EmailVerificationClaim, |
| 53 | + EmailVerificationRecipe, |
55 | 54 | ) |
56 | 55 | from supertokens_python.recipe.emailverification import ( |
57 | 56 | InputOverrideConfig as EVInputOverrideConfig, |
58 | 57 | ) |
59 | | -from supertokens_python.recipe.emailverification.asyncio import unverify_email |
60 | 58 | from supertokens_python.recipe.emailverification.interfaces import ( |
61 | 59 | APIInterface as EmailVerificationAPIInterface, |
62 | 60 | ) |
63 | 61 | from supertokens_python.recipe.emailverification.interfaces import ( |
64 | 62 | APIOptions as EVAPIOptions, |
65 | 63 | ) |
| 64 | +from supertokens_python.recipe.emailverification.syncio import unverify_email |
66 | 65 | from supertokens_python.recipe.emailverification.types import User as EVUser |
67 | 66 | from supertokens_python.recipe.jwt import JWTRecipe |
68 | 67 | from supertokens_python.recipe.passwordless import ( |
|
81 | 80 | from supertokens_python.recipe.session.framework.flask import verify_session |
82 | 81 | from supertokens_python.recipe.session.interfaces import ( |
83 | 82 | APIInterface as SessionAPIInterface, |
84 | | - SessionContainer, |
85 | | - SessionClaimValidator, |
86 | 83 | ) |
87 | 84 | from supertokens_python.recipe.session.interfaces import APIOptions as SAPIOptions |
| 85 | +from supertokens_python.recipe.session.interfaces import ( |
| 86 | + SessionClaimValidator, |
| 87 | + SessionContainer, |
| 88 | +) |
88 | 89 | from supertokens_python.recipe.thirdparty import ThirdPartyRecipe |
89 | 90 | from supertokens_python.recipe.thirdparty.interfaces import ( |
90 | 91 | APIInterface as ThirdpartyAPIInterface, |
|
113 | 114 | APIInterface as ThirdpartyPasswordlessAPIInterface, |
114 | 115 | ) |
115 | 116 | from supertokens_python.recipe.userroles import ( |
116 | | - UserRoleClaim, |
117 | 117 | PermissionClaim, |
| 118 | + UserRoleClaim, |
118 | 119 | UserRolesRecipe, |
119 | 120 | ) |
120 | | -from supertokens_python.recipe.userroles.asyncio import ( |
121 | | - create_new_role_or_add_permissions, |
| 121 | +from supertokens_python.recipe.userroles.syncio import ( |
122 | 122 | add_role_to_user, |
| 123 | + create_new_role_or_add_permissions, |
123 | 124 | ) |
124 | 125 | from supertokens_python.types import GeneralErrorResponse |
125 | 126 | from typing_extensions import Literal |
@@ -1011,7 +1012,7 @@ def before_each(): |
1011 | 1012 |
|
1012 | 1013 |
|
1013 | 1014 | @app.route("/test/setFlow", methods=["POST"]) # type: ignore |
1014 | | -async def test_set_flow(): |
| 1015 | +def test_set_flow(): |
1015 | 1016 | body: Union[Any, None] = request.get_json() |
1016 | 1017 | if body is None: |
1017 | 1018 | raise Exception("Should never come here") |
@@ -1039,22 +1040,22 @@ def test_feature_flags(): |
1039 | 1040 |
|
1040 | 1041 | @app.get("/unverifyEmail") # type: ignore |
1041 | 1042 | @verify_session() |
1042 | | -async def unverify_email_api(): |
| 1043 | +def unverify_email_api(): |
1043 | 1044 | session_: SessionContainer = g.supertokens # type: ignore |
1044 | | - await unverify_email(session_.get_user_id()) |
1045 | | - await session_.fetch_and_set_claim(EmailVerificationClaim) |
| 1045 | + unverify_email(session_.get_user_id()) |
| 1046 | + session_.sync_fetch_and_set_claim(EmailVerificationClaim) |
1046 | 1047 | return jsonify({"status": "OK"}) |
1047 | 1048 |
|
1048 | 1049 |
|
1049 | 1050 | @app.route("/setRole", methods=["POST"]) # type: ignore |
1050 | 1051 | @verify_session() |
1051 | | -async def verify_email_api(): |
| 1052 | +def verify_email_api(): |
1052 | 1053 | session_: SessionContainer = g.supertokens # type: ignore |
1053 | 1054 | body: Dict[str, Any] = request.get_json() # type: ignore |
1054 | | - await create_new_role_or_add_permissions(body["role"], body["permissions"]) |
1055 | | - await add_role_to_user(session_.get_user_id(), body["role"]) |
1056 | | - await session_.fetch_and_set_claim(UserRoleClaim) |
1057 | | - await session_.fetch_and_set_claim(PermissionClaim) |
| 1055 | + create_new_role_or_add_permissions(body["role"], body["permissions"]) |
| 1056 | + add_role_to_user(session_.get_user_id(), body["role"]) |
| 1057 | + session_.sync_fetch_and_set_claim(UserRoleClaim) |
| 1058 | + session_.sync_fetch_and_set_claim(PermissionClaim) |
1058 | 1059 | return jsonify({"status": "OK"}) |
1059 | 1060 |
|
1060 | 1061 |
|
@@ -1082,7 +1083,7 @@ async def override_global_claim_validators( |
1082 | 1083 |
|
1083 | 1084 | @app.route("/checkRole", methods=["POST"]) # type: ignore |
1084 | 1085 | @verify_session(override_global_claim_validators=override_global_claim_validators) |
1085 | | -async def check_role_api(): |
| 1086 | +def check_role_api(): |
1086 | 1087 | return jsonify({"status": "OK"}) |
1087 | 1088 |
|
1088 | 1089 |
|
|
0 commit comments