Skip to content

fix: Import SignUpPostOkResult instead of SignUpOkResult #266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Fixes issue of sign up API not sending a `FIELD_ERROR` response in case of duplicate email: https://github.com/supertokens/supertokens-python/issues/264


## [0.11.9] - 2022-12-06

- Fixes issue where if send_email is overridden with a different email, it will reset that email.
Expand Down
30 changes: 14 additions & 16 deletions supertokens_python/recipe/emailpassword/api/signup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@

from typing import TYPE_CHECKING, Any

from ..exceptions import raise_form_field_exception
from supertokens_python.recipe.emailpassword.interfaces import (
SignUpOkResult,
SignUpPostEmailAlreadyExistsError,
)
from supertokens_python.recipe.emailpassword.interfaces import SignUpPostOkResult
from supertokens_python.types import GeneralErrorResponse

from ..exceptions import raise_form_field_exception
from ..types import ErrorFormField

if TYPE_CHECKING:
Expand Down Expand Up @@ -51,17 +49,17 @@ async def handle_sign_up_api(api_implementation: APIInterface, api_options: APIO
form_fields, api_options, user_context
)

if isinstance(response, SignUpOkResult):
if isinstance(response, SignUpPostOkResult):
return send_200_response(response.to_json(), api_options.response)
if isinstance(response, GeneralErrorResponse):
return send_200_response(response.to_json(), api_options.response)
if isinstance(response, SignUpPostEmailAlreadyExistsError):
return raise_form_field_exception(
"EMAIL_ALREADY_EXISTS_ERROR",
[
ErrorFormField(
id="email",
error="This email already exists. Please sign in instead.",
)
],
)

return raise_form_field_exception(
"EMAIL_ALREADY_EXISTS_ERROR",
[
ErrorFormField(
id="email",
error="This email already exists. Please sign in instead.",
)
],
)