Skip to content

Commit a000d3c

Browse files
Merge pull request #221 from supertokens/feat/session-grants-new
feat(session): Review based changes
2 parents 9879067 + 0e3fd33 commit a000d3c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+421
-439
lines changed

supertokens_python/post_init_callbacks.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
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+
115
from typing import Callable, List
216

317

supertokens_python/recipe/emailpassword/emaildelivery/services/smtp/service_implementation/__init__.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
from typing import Any, Dict
1616

17-
from supertokens_python.ingredients.emaildelivery.services.smtp import Transporter
1817
from supertokens_python.ingredients.emaildelivery.types import (
1918
EmailContent,
2019
SMTPServiceInterface,
@@ -23,21 +22,9 @@
2322
get_password_reset_email_content,
2423
)
2524
from supertokens_python.recipe.emailpassword.types import EmailTemplateVars
26-
from supertokens_python.recipe.emailverification.emaildelivery.services.smtp.service_implementation import (
27-
ServiceImplementation as EVServiceImplementation,
28-
)
2925

3026

3127
class ServiceImplementation(SMTPServiceInterface[EmailTemplateVars]):
32-
def __init__(self, transporter: Transporter) -> None:
33-
super().__init__(transporter)
34-
35-
email_verification_service_implementation = EVServiceImplementation(transporter)
36-
self.ev_send_raw_email = (
37-
email_verification_service_implementation.send_raw_email
38-
)
39-
self.ev_get_content = email_verification_service_implementation.get_content
40-
4128
async def send_raw_email(
4229
self, content: EmailContent, user_context: Dict[str, Any]
4330
) -> None:

supertokens_python/recipe/emailpassword/recipe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ async def handle_api_request(
189189
)
190190
if request_id == USER_PASSWORD_RESET:
191191
return await handle_password_reset_api(self.api_implementation, api_options)
192-
# FIXME: Should be False as per Node PR but the spec here don't allow it.
192+
193193
return None
194194

195195
async def handle_error(

supertokens_python/recipe/emailverification/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
from .emaildelivery import services as emaildelivery_services
2121
from . import recipe
2222
from .interfaces import TypeGetEmailForUserIdFunction
23+
from .recipe import EmailVerificationRecipe
2324
from .types import EmailTemplateVars, User
2425
from ...ingredients.emaildelivery.types import EmailDeliveryConfig
2526

2627
InputOverrideConfig = utils.OverrideConfig
2728
exception = ex
2829
SMTPService = emaildelivery_services.SMTPService
2930
EmailVerificationClaim = recipe.EmailVerificationClaim
30-
EmailVerificationRecipe = recipe.EmailVerificationRecipe
3131

3232

3333
if TYPE_CHECKING:

supertokens_python/recipe/emailverification/api/email_verify.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async def handle_email_verify_api(
5252
)
5353

5454
result = await api_implementation.email_verify_post(
55-
token, api_options, session, user_context
55+
token, session, api_options, user_context
5656
)
5757
else:
5858
if api_implementation.disable_is_email_verified_get:
@@ -63,9 +63,9 @@ async def handle_email_verify_api(
6363
override_global_claim_validators=lambda _, __, ___: [],
6464
user_context=user_context,
6565
)
66-
66+
assert session is not None
6767
result = await api_implementation.is_email_verified_get(
68-
api_options, session, user_context
68+
session, api_options, user_context
6969
)
7070

7171
return send_200_response(result.to_json(), api_options.response)

supertokens_python/recipe/emailverification/api/generate_email_verify_token.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ async def handle_generate_email_verify_token_api(
3535
assert session is not None
3636

3737
result = await api_implementation.generate_email_verify_token_post(
38-
api_options, session, user_context
38+
session, api_options, user_context
3939
)
4040
return send_200_response(result.to_json(), api_options.response)

supertokens_python/recipe/emailverification/asyncio/__init__.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
CreateEmailVerificationTokenEmailAlreadyVerifiedError,
1919
UnverifyEmailOkResult,
2020
CreateEmailVerificationTokenOkResult,
21+
RevokeEmailVerificationTokensOkResult,
2122
)
2223
from supertokens_python.recipe.emailverification.types import EmailTemplateVars
2324
from supertokens_python.recipe.emailverification.recipe import EmailVerificationRecipe
@@ -81,11 +82,11 @@ async def is_email_verified(
8182
)
8283

8384

84-
async def revoke_email_verification_token(
85+
async def revoke_email_verification_tokens(
8586
user_id: str,
8687
email: Optional[str] = None,
8788
user_context: Optional[Dict[str, Any]] = None,
88-
):
89+
) -> RevokeEmailVerificationTokensOkResult:
8990
if user_context is None:
9091
user_context = {}
9192

@@ -95,9 +96,7 @@ async def revoke_email_verification_token(
9596
if isinstance(email_info, GetEmailForUserIdOkResult):
9697
email = email_info.email
9798
elif isinstance(email_info, EmailDoesNotExistError):
98-
# Here we are returning OK since that's how it used to work, but a later call
99-
# to is_verified will still return true
100-
return CreateEmailVerificationTokenEmailAlreadyVerifiedError()
99+
return RevokeEmailVerificationTokensOkResult()
101100
else:
102101
raise Exception("Unknown User ID provided without email")
103102

@@ -131,16 +130,6 @@ async def unverify_email(
131130
)
132131

133132

134-
async def revoke_email_verification_tokens(
135-
user_id: str, email: str, user_context: Union[None, Dict[str, Any]] = None
136-
):
137-
if user_context is None:
138-
user_context = {}
139-
return await EmailVerificationRecipe.get_instance().recipe_implementation.revoke_email_verification_tokens(
140-
user_id, email, user_context
141-
)
142-
143-
144133
async def send_email(
145134
input_: EmailTemplateVars, user_context: Union[None, Dict[str, Any]] = None
146135
):

supertokens_python/recipe/emailverification/ev_claim.py

Lines changed: 0 additions & 82 deletions
This file was deleted.

supertokens_python/recipe/emailverification/api/implementation.py renamed to supertokens_python/recipe/emailverification/ev_claim_validators.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,3 @@
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
1414
from __future__ import annotations
15-
16-
from typing import TYPE_CHECKING
17-
18-
if TYPE_CHECKING:
19-
pass

supertokens_python/recipe/emailverification/interfaces.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ def __init__(self):
167167
async def email_verify_post(
168168
self,
169169
token: str,
170-
api_options: APIOptions,
171170
session: Optional[SessionContainer],
171+
api_options: APIOptions,
172172
user_context: Dict[str, Any],
173173
) -> Union[
174174
EmailVerifyPostOkResult, EmailVerifyPostInvalidTokenError, GeneralErrorResponse
@@ -178,17 +178,17 @@ async def email_verify_post(
178178
@abstractmethod
179179
async def is_email_verified_get(
180180
self,
181+
session: SessionContainer,
181182
api_options: APIOptions,
182-
session: Optional[SessionContainer],
183183
user_context: Dict[str, Any],
184184
) -> Union[IsEmailVerifiedGetOkResult, GeneralErrorResponse]:
185185
pass
186186

187187
@abstractmethod
188188
async def generate_email_verify_token_post(
189189
self,
190-
api_options: APIOptions,
191190
session: SessionContainer,
191+
api_options: APIOptions,
192192
user_context: Dict[str, Any],
193193
) -> Union[
194194
GenerateEmailVerifyTokenPostOkResult,

0 commit comments

Comments
 (0)