Skip to content

Commit 89b7be2

Browse files
committed
adding dev-v0.24.3 tag to this commit to ensure building
1 parent b6851db commit 89b7be2

File tree

4 files changed

+48
-27
lines changed

4 files changed

+48
-27
lines changed

html/supertokens_python/constants.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ <h1 class="title">Module <code>supertokens_python.constants</code></h1>
4242
from __future__ import annotations
4343

4444
SUPPORTED_CDI_VERSIONS = [&#34;3.0&#34;]
45-
VERSION = &#34;0.24.2&#34;
45+
VERSION = &#34;0.24.3&#34;
4646
TELEMETRY = &#34;/telemetry&#34;
4747
USER_COUNT = &#34;/users/count&#34;
4848
USER_DELETE = &#34;/user/remove&#34;

html/supertokens_python/recipe/emailpassword/api/utils.html

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ <h1 class="title">Module <code>supertokens_python.recipe.emailpassword.api.utils
4444
from typing import Any, Dict, List, Union
4545

4646
from supertokens_python.exceptions import raise_bad_input_exception
47-
from supertokens_python.recipe.emailpassword.constants import FORM_FIELD_EMAIL_ID
47+
from supertokens_python.recipe.emailpassword.constants import (
48+
FORM_FIELD_EMAIL_ID,
49+
FORM_FIELD_PASSWORD_ID,
50+
)
4851
from supertokens_python.recipe.emailpassword.exceptions import (
4952
raise_form_field_exception,
5053
)
@@ -69,7 +72,9 @@ <h1 class="title">Module <code>supertokens_python.recipe.emailpassword.api.utils
6972
input_field: Union[None, FormField] = find_first_occurrence_in_list(
7073
lambda x: x.id == field.id, inputs
7174
)
72-
is_invalid_value = input_field is None or input_field.value == &#34;&#34;
75+
is_invalid_value = input_field is None or (
76+
isinstance(input_field.value, str) and input_field.value == &#34;&#34;
77+
)
7378
if not field.optional and is_invalid_value:
7479
validation_errors.append(ErrorFormField(field.id, &#34;Field is not optional&#34;))
7580
continue
@@ -111,7 +116,18 @@ <h1 class="title">Module <code>supertokens_python.recipe.emailpassword.api.utils
111116
raise_bad_input_exception(
112117
&#34;All elements of formFields must contain an &#39;id&#39; and &#39;value&#39; field&#34;
113118
)
119+
114120
value = current_form_field[&#34;value&#34;]
121+
if current_form_field[&#34;id&#34;] in [
122+
FORM_FIELD_EMAIL_ID,
123+
FORM_FIELD_PASSWORD_ID,
124+
] and not isinstance(value, str):
125+
# Ensure that the type is string else we will throw a bad input
126+
# error.
127+
raise_bad_input_exception(
128+
f&#34;{current_form_field[&#39;id&#39;]} value must be a string&#34;
129+
)
130+
115131
if current_form_field[&#34;id&#34;] == FORM_FIELD_EMAIL_ID and isinstance(value, str):
116132
value = value.strip()
117133
form_fields.append(FormField(current_form_field[&#34;id&#34;], value))
@@ -157,7 +173,18 @@ <h2 class="section-title" id="header-functions">Functions</h2>
157173
raise_bad_input_exception(
158174
&#34;All elements of formFields must contain an &#39;id&#39; and &#39;value&#39; field&#34;
159175
)
176+
160177
value = current_form_field[&#34;value&#34;]
178+
if current_form_field[&#34;id&#34;] in [
179+
FORM_FIELD_EMAIL_ID,
180+
FORM_FIELD_PASSWORD_ID,
181+
] and not isinstance(value, str):
182+
# Ensure that the type is string else we will throw a bad input
183+
# error.
184+
raise_bad_input_exception(
185+
f&#34;{current_form_field[&#39;id&#39;]} value must be a string&#34;
186+
)
187+
161188
if current_form_field[&#34;id&#34;] == FORM_FIELD_EMAIL_ID and isinstance(value, str):
162189
value = value.strip()
163190
form_fields.append(FormField(current_form_field[&#34;id&#34;], value))
@@ -188,7 +215,9 @@ <h2 class="section-title" id="header-functions">Functions</h2>
188215
input_field: Union[None, FormField] = find_first_occurrence_in_list(
189216
lambda x: x.id == field.id, inputs
190217
)
191-
is_invalid_value = input_field is None or input_field.value == &#34;&#34;
218+
is_invalid_value = input_field is None or (
219+
isinstance(input_field.value, str) and input_field.value == &#34;&#34;
220+
)
192221
if not field.optional and is_invalid_value:
193222
validation_errors.append(ErrorFormField(field.id, &#34;Field is not optional&#34;))
194223
continue

html/supertokens_python/recipe/emailpassword/types.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ <h1 class="title">Module <code>supertokens_python.recipe.emailpassword.types</co
4040
# License for the specific language governing permissions and limitations
4141
# under the License.
4242
from __future__ import annotations
43-
from typing import Awaitable, Callable, List, TypeVar, Union
43+
44+
from typing import Any, Awaitable, Callable, List, TypeVar, Union
4445

4546
from supertokens_python.ingredients.emaildelivery import EmailDeliveryIngredient
4647
from supertokens_python.ingredients.emaildelivery.types import (
@@ -81,9 +82,9 @@ <h1 class="title">Module <code>supertokens_python.recipe.emailpassword.types</co
8182

8283

8384
class FormField:
84-
def __init__(self, id: str, value: str): # pylint: disable=redefined-builtin
85+
def __init__(self, id: str, value: Any): # pylint: disable=redefined-builtin
8586
self.id: str = id
86-
self.value: str = value
87+
self.value: Any = value
8788

8889

8990
class InputFormField:
@@ -197,7 +198,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
197198
</dd>
198199
<dt id="supertokens_python.recipe.emailpassword.types.FormField"><code class="flex name class">
199200
<span>class <span class="ident">FormField</span></span>
200-
<span>(</span><span>id: str, value: str)</span>
201+
<span>(</span><span>id: str, value: Any)</span>
201202
</code></dt>
202203
<dd>
203204
<div class="desc"></div>
@@ -206,9 +207,9 @@ <h2 class="section-title" id="header-classes">Classes</h2>
206207
<span>Expand source code</span>
207208
</summary>
208209
<pre><code class="python">class FormField:
209-
def __init__(self, id: str, value: str): # pylint: disable=redefined-builtin
210+
def __init__(self, id: str, value: Any): # pylint: disable=redefined-builtin
210211
self.id: str = id
211-
self.value: str = value</code></pre>
212+
self.value: Any = value</code></pre>
212213
</details>
213214
</dd>
214215
<dt id="supertokens_python.recipe.emailpassword.types.InputFormField"><code class="flex name class">

html/supertokens_python/recipe/emailpassword/utils.html

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ <h1 class="title">Module <code>supertokens_python.recipe.emailpassword.utils</co
4242
from __future__ import annotations
4343

4444
from re import fullmatch
45-
from typing import TYPE_CHECKING, Any, Callable, List, Optional, Union, Dict
46-
from supertokens_python.framework import BaseRequest
45+
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Union
4746

47+
from supertokens_python.framework import BaseRequest
4848
from supertokens_python.ingredients.emaildelivery.types import (
4949
EmailDeliveryConfig,
5050
EmailDeliveryConfigWithService,
@@ -54,17 +54,14 @@ <h1 class="title">Module <code>supertokens_python.recipe.emailpassword.utils</co
5454
)
5555

5656
from .interfaces import APIInterface, RecipeInterface
57-
from .types import InputFormField, NormalisedFormField, EmailTemplateVars
57+
from .types import EmailTemplateVars, InputFormField, NormalisedFormField
5858

5959
if TYPE_CHECKING:
6060
from supertokens_python.supertokens import AppInfo
6161

6262
from supertokens_python.utils import get_filtered_list
6363

64-
from .constants import (
65-
FORM_FIELD_EMAIL_ID,
66-
FORM_FIELD_PASSWORD_ID,
67-
)
64+
from .constants import FORM_FIELD_EMAIL_ID, FORM_FIELD_PASSWORD_ID
6865

6966

7067
async def default_validator(_: str, __: str) -&gt; Union[str, None]:
@@ -289,11 +286,8 @@ <h1 class="title">Module <code>supertokens_python.recipe.emailpassword.utils</co
289286
email_delivery: Union[EmailDeliveryConfig[EmailTemplateVars], None] = None,
290287
) -&gt; EmailPasswordConfig:
291288

292-
if sign_up_feature is not None and not isinstance(sign_up_feature, InputSignUpFeature): # type: ignore
293-
raise ValueError(&#34;sign_up_feature must be of type InputSignUpFeature or None&#34;)
294-
295-
if override is not None and not isinstance(override, InputOverrideConfig): # type: ignore
296-
raise ValueError(&#34;override must be of type InputOverrideConfig or None&#34;)
289+
# NOTE: We don&#39;t need to check the instance of sign_up_feature and override
290+
# as they will always be either None or the specified type.
297291

298292
if override is None:
299293
override = InputOverrideConfig()
@@ -607,11 +601,8 @@ <h2 class="section-title" id="header-functions">Functions</h2>
607601
email_delivery: Union[EmailDeliveryConfig[EmailTemplateVars], None] = None,
608602
) -&gt; EmailPasswordConfig:
609603

610-
if sign_up_feature is not None and not isinstance(sign_up_feature, InputSignUpFeature): # type: ignore
611-
raise ValueError(&#34;sign_up_feature must be of type InputSignUpFeature or None&#34;)
612-
613-
if override is not None and not isinstance(override, InputOverrideConfig): # type: ignore
614-
raise ValueError(&#34;override must be of type InputOverrideConfig or None&#34;)
604+
# NOTE: We don&#39;t need to check the instance of sign_up_feature and override
605+
# as they will always be either None or the specified type.
615606

616607
if override is None:
617608
override = InputOverrideConfig()

0 commit comments

Comments
 (0)