@@ -43,6 +43,14 @@ <h1 class="title">Module <code>supertokens_python.recipe.emailpassword.api.signu
43
43
44
44
from typing import TYPE_CHECKING, Any
45
45
46
+ from ..exceptions import raise_form_field_exception
47
+ from supertokens_python.recipe.emailpassword.interfaces import (
48
+ SignUpOkResult,
49
+ SignUpPostEmailAlreadyExistsError,
50
+ )
51
+ from supertokens_python.types import GeneralErrorResponse
52
+ from ..types import ErrorFormField
53
+
46
54
if TYPE_CHECKING:
47
55
from supertokens_python.recipe.emailpassword.interfaces import (
48
56
APIOptions,
@@ -71,7 +79,20 @@ <h1 class="title">Module <code>supertokens_python.recipe.emailpassword.api.signu
71
79
form_fields, api_options, user_context
72
80
)
73
81
74
- return send_200_response(response.to_json(), api_options.response)</ code > </ pre >
82
+ if isinstance(response, SignUpOkResult):
83
+ return send_200_response(response.to_json(), api_options.response)
84
+ if isinstance(response, GeneralErrorResponse):
85
+ return send_200_response(response.to_json(), api_options.response)
86
+ if isinstance(response, SignUpPostEmailAlreadyExistsError):
87
+ return raise_form_field_exception(
88
+ "EMAIL_ALREADY_EXISTS_ERROR",
89
+ [
90
+ ErrorFormField(
91
+ id="email",
92
+ error="This email already exists. Please sign in instead.",
93
+ )
94
+ ],
95
+ )</ code > </ pre >
75
96
</ details >
76
97
</ section >
77
98
< section >
@@ -106,7 +127,20 @@ <h2 class="section-title" id="header-functions">Functions</h2>
106
127
form_fields, api_options, user_context
107
128
)
108
129
109
- return send_200_response(response.to_json(), api_options.response)</ code > </ pre >
130
+ if isinstance(response, SignUpOkResult):
131
+ return send_200_response(response.to_json(), api_options.response)
132
+ if isinstance(response, GeneralErrorResponse):
133
+ return send_200_response(response.to_json(), api_options.response)
134
+ if isinstance(response, SignUpPostEmailAlreadyExistsError):
135
+ return raise_form_field_exception(
136
+ "EMAIL_ALREADY_EXISTS_ERROR",
137
+ [
138
+ ErrorFormField(
139
+ id="email",
140
+ error="This email already exists. Please sign in instead.",
141
+ )
142
+ ],
143
+ )</ code > </ pre >
110
144
</ details >
111
145
</ dd >
112
146
</ dl >
0 commit comments