Skip to content

Commit 4235dd9

Browse files
committed
adding dev-v0.18.0 tag to this commit to ensure building
1 parent 6295c4b commit 4235dd9

File tree

41 files changed

+1109
-390
lines changed

Some content is hidden

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

41 files changed

+1109
-390
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.17.0&#34;
45+
VERSION = &#34;0.18.0&#34;
4646
TELEMETRY = &#34;/telemetry&#34;
4747
USER_COUNT = &#34;/users/count&#34;
4848
USER_DELETE = &#34;/user/remove&#34;

html/supertokens_python/framework/django/django_middleware.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ <h1 class="title">Module <code>supertokens_python.framework.django.django_middle
7777
request.supertokens, SessionContainer # type: ignore
7878
):
7979
manage_session_post_response(
80-
request.supertokens, result # type: ignore
80+
request.supertokens, result, user_context # type: ignore
8181
)
8282
if isinstance(result, DjangoResponse):
8383
return result.response
8484
except SuperTokensError as e:
8585
response = DjangoResponse(HttpResponse())
8686
result = await st.handle_supertokens_error(
87-
DjangoRequest(request), e, response
87+
DjangoRequest(request), e, response, user_context
8888
)
8989
if isinstance(result, DjangoResponse):
9090
return result.response
@@ -113,15 +113,15 @@ <h1 class="title">Module <code>supertokens_python.framework.django.django_middle
113113
request.supertokens, SessionContainer # type: ignore
114114
):
115115
manage_session_post_response(
116-
request.supertokens, result # type: ignore
116+
request.supertokens, result, user_context # type: ignore
117117
)
118118
return result.response
119119

120120
except SuperTokensError as e:
121121
response = DjangoResponse(HttpResponse())
122122
result: Union[DjangoResponse, None] = async_to_sync(
123123
st.handle_supertokens_error
124-
)(DjangoRequest(request), e, response)
124+
)(DjangoRequest(request), e, response, user_context)
125125
if result is not None:
126126
return result.response
127127
raise Exception(&#34;Should never come here&#34;)
@@ -175,14 +175,14 @@ <h2 class="section-title" id="header-functions">Functions</h2>
175175
request.supertokens, SessionContainer # type: ignore
176176
):
177177
manage_session_post_response(
178-
request.supertokens, result # type: ignore
178+
request.supertokens, result, user_context # type: ignore
179179
)
180180
if isinstance(result, DjangoResponse):
181181
return result.response
182182
except SuperTokensError as e:
183183
response = DjangoResponse(HttpResponse())
184184
result = await st.handle_supertokens_error(
185-
DjangoRequest(request), e, response
185+
DjangoRequest(request), e, response, user_context
186186
)
187187
if isinstance(result, DjangoResponse):
188188
return result.response
@@ -211,15 +211,15 @@ <h2 class="section-title" id="header-functions">Functions</h2>
211211
request.supertokens, SessionContainer # type: ignore
212212
):
213213
manage_session_post_response(
214-
request.supertokens, result # type: ignore
214+
request.supertokens, result, user_context # type: ignore
215215
)
216216
return result.response
217217

218218
except SuperTokensError as e:
219219
response = DjangoResponse(HttpResponse())
220220
result: Union[DjangoResponse, None] = async_to_sync(
221221
st.handle_supertokens_error
222-
)(DjangoRequest(request), e, response)
222+
)(DjangoRequest(request), e, response, user_context)
223223
if result is not None:
224224
return result.response
225225
raise Exception(&#34;Should never come here&#34;)

html/supertokens_python/framework/fastapi/fastapi_middleware.html

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,11 @@ <h1 class="title">Module <code>supertokens_python.framework.fastapi.fastapi_midd
7272
st = Supertokens.get_instance()
7373
from fastapi.responses import Response
7474

75+
custom_request = FastApiRequest(request)
76+
response = FastApiResponse(Response())
77+
user_context = default_user_context(custom_request)
78+
7579
try:
76-
custom_request = FastApiRequest(request)
77-
response = FastApiResponse(Response())
78-
user_context = default_user_context(custom_request)
7980
result: Union[BaseResponse, None] = await st.middleware(
8081
custom_request, response, user_context
8182
)
@@ -86,13 +87,15 @@ <h1 class="title">Module <code>supertokens_python.framework.fastapi.fastapi_midd
8687
if hasattr(request.state, &#34;supertokens&#34;) and isinstance(
8788
request.state.supertokens, SessionContainer
8889
):
89-
manage_session_post_response(request.state.supertokens, result)
90+
manage_session_post_response(
91+
request.state.supertokens, result, user_context
92+
)
9093
if isinstance(result, FastApiResponse):
9194
return result.response
9295
except SuperTokensError as e:
9396
response = FastApiResponse(Response())
9497
result: Union[BaseResponse, None] = await st.handle_supertokens_error(
95-
FastApiRequest(request), e, response
98+
FastApiRequest(request), e, response, user_context
9699
)
97100
if isinstance(result, FastApiResponse):
98101
return result.response
@@ -141,10 +144,11 @@ <h2 class="section-title" id="header-functions">Functions</h2>
141144
st = Supertokens.get_instance()
142145
from fastapi.responses import Response
143146

147+
custom_request = FastApiRequest(request)
148+
response = FastApiResponse(Response())
149+
user_context = default_user_context(custom_request)
150+
144151
try:
145-
custom_request = FastApiRequest(request)
146-
response = FastApiResponse(Response())
147-
user_context = default_user_context(custom_request)
148152
result: Union[BaseResponse, None] = await st.middleware(
149153
custom_request, response, user_context
150154
)
@@ -155,13 +159,15 @@ <h2 class="section-title" id="header-functions">Functions</h2>
155159
if hasattr(request.state, &#34;supertokens&#34;) and isinstance(
156160
request.state.supertokens, SessionContainer
157161
):
158-
manage_session_post_response(request.state.supertokens, result)
162+
manage_session_post_response(
163+
request.state.supertokens, result, user_context
164+
)
159165
if isinstance(result, FastApiResponse):
160166
return result.response
161167
except SuperTokensError as e:
162168
response = FastApiResponse(Response())
163169
result: Union[BaseResponse, None] = await st.handle_supertokens_error(
164-
FastApiRequest(request), e, response
170+
FastApiRequest(request), e, response, user_context
165171
)
166172
if isinstance(result, FastApiResponse):
167173
return result.response

html/supertokens_python/framework/flask/flask_middleware.html

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ <h1 class="title">Module <code>supertokens_python.framework.flask.flask_middlewa
9797

9898
response_ = FlaskResponse(response)
9999
if hasattr(g, &#34;supertokens&#34;) and g.supertokens is not None:
100-
manage_session_post_response(g.supertokens, response_)
100+
manage_session_post_response(g.supertokens, response_, {})
101101

102102
return response_.response
103103

@@ -112,15 +112,21 @@ <h1 class="title">Module <code>supertokens_python.framework.flask.flask_middlewa
112112
from supertokens_python import Supertokens
113113
from supertokens_python.framework.flask.flask_request import FlaskRequest
114114
from supertokens_python.framework.flask.flask_response import FlaskResponse
115+
from supertokens_python.utils import default_user_context
115116

116117
from flask.wrappers import Response
117118

118119
st = Supertokens.get_instance()
119120
response = Response(json.dumps({}), mimetype=&#34;application/json&#34;, status=200)
121+
base_request = FlaskRequest(request)
122+
user_context = default_user_context(base_request)
120123

121124
result: BaseResponse = sync(
122125
st.handle_supertokens_error(
123-
FlaskRequest(request), error, FlaskResponse(response)
126+
base_request,
127+
error,
128+
FlaskResponse(response),
129+
user_context,
124130
)
125131
)
126132
if isinstance(result, FlaskResponse):
@@ -193,7 +199,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
193199

194200
response_ = FlaskResponse(response)
195201
if hasattr(g, &#34;supertokens&#34;) and g.supertokens is not None:
196-
manage_session_post_response(g.supertokens, response_)
202+
manage_session_post_response(g.supertokens, response_, {})
197203

198204
return response_.response
199205

@@ -208,15 +214,21 @@ <h2 class="section-title" id="header-classes">Classes</h2>
208214
from supertokens_python import Supertokens
209215
from supertokens_python.framework.flask.flask_request import FlaskRequest
210216
from supertokens_python.framework.flask.flask_response import FlaskResponse
217+
from supertokens_python.utils import default_user_context
211218

212219
from flask.wrappers import Response
213220

214221
st = Supertokens.get_instance()
215222
response = Response(json.dumps({}), mimetype=&#34;application/json&#34;, status=200)
223+
base_request = FlaskRequest(request)
224+
user_context = default_user_context(base_request)
216225

217226
result: BaseResponse = sync(
218227
st.handle_supertokens_error(
219-
FlaskRequest(request), error, FlaskResponse(response)
228+
base_request,
229+
error,
230+
FlaskResponse(response),
231+
user_context,
220232
)
221233
)
222234
if isinstance(result, FlaskResponse):
@@ -274,7 +286,7 @@ <h3>Methods</h3>
274286

275287
response_ = FlaskResponse(response)
276288
if hasattr(g, &#34;supertokens&#34;) and g.supertokens is not None:
277-
manage_session_post_response(g.supertokens, response_)
289+
manage_session_post_response(g.supertokens, response_, {})
278290

279291
return response_.response</code></pre>
280292
</details>
@@ -299,15 +311,21 @@ <h3>Methods</h3>
299311
from supertokens_python import Supertokens
300312
from supertokens_python.framework.flask.flask_request import FlaskRequest
301313
from supertokens_python.framework.flask.flask_response import FlaskResponse
314+
from supertokens_python.utils import default_user_context
302315

303316
from flask.wrappers import Response
304317

305318
st = Supertokens.get_instance()
306319
response = Response(json.dumps({}), mimetype=&#34;application/json&#34;, status=200)
320+
base_request = FlaskRequest(request)
321+
user_context = default_user_context(base_request)
307322

308323
result: BaseResponse = sync(
309324
st.handle_supertokens_error(
310-
FlaskRequest(request), error, FlaskResponse(response)
325+
base_request,
326+
error,
327+
FlaskResponse(response),
328+
user_context,
311329
)
312330
)
313331
if isinstance(result, FlaskResponse):

html/supertokens_python/recipe/dashboard/api/analytics.html

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,8 @@ <h1 class="title">Module <code>supertokens_python.recipe.dashboard.api.analytics
8989
None,
9090
_user_context,
9191
)
92-
if response is not None:
93-
if (
94-
&#34;exists&#34; in response
95-
and response[&#34;exists&#34;]
96-
and &#34;telemetryId&#34; in response
97-
):
98-
telemetry_id = response[&#34;telemetryId&#34;]
92+
if &#34;exists&#34; in response and response[&#34;exists&#34;] and &#34;telemetryId&#34; in response:
93+
telemetry_id = response[&#34;telemetryId&#34;]
9994

10095
number_of_users = await Supertokens.get_instance().get_user_count(
10196
include_recipe_ids=None
@@ -107,7 +102,7 @@ <h1 class="title">Module <code>supertokens_python.recipe.dashboard.api.analytics
107102

108103
apiDomain, websiteDomain, appName = (
109104
api_options.app_info.api_domain,
110-
api_options.app_info.website_domain,
105+
api_options.app_info.get_origin(api_options.request, {}),
111106
api_options.app_info.app_name,
112107
)
113108

@@ -182,13 +177,8 @@ <h2 class="section-title" id="header-functions">Functions</h2>
182177
None,
183178
_user_context,
184179
)
185-
if response is not None:
186-
if (
187-
&#34;exists&#34; in response
188-
and response[&#34;exists&#34;]
189-
and &#34;telemetryId&#34; in response
190-
):
191-
telemetry_id = response[&#34;telemetryId&#34;]
180+
if &#34;exists&#34; in response and response[&#34;exists&#34;] and &#34;telemetryId&#34; in response:
181+
telemetry_id = response[&#34;telemetryId&#34;]
192182

193183
number_of_users = await Supertokens.get_instance().get_user_count(
194184
include_recipe_ids=None
@@ -200,7 +190,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
200190

201191
apiDomain, websiteDomain, appName = (
202192
api_options.app_info.api_domain,
203-
api_options.app_info.website_domain,
193+
api_options.app_info.get_origin(api_options.request, {}),
204194
api_options.app_info.app_name,
205195
)
206196

html/supertokens_python/recipe/dashboard/api/index.html

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,8 @@ <h2 class="section-title" id="header-functions">Functions</h2>
220220
None,
221221
_user_context,
222222
)
223-
if response is not None:
224-
if (
225-
&#34;exists&#34; in response
226-
and response[&#34;exists&#34;]
227-
and &#34;telemetryId&#34; in response
228-
):
229-
telemetry_id = response[&#34;telemetryId&#34;]
223+
if &#34;exists&#34; in response and response[&#34;exists&#34;] and &#34;telemetryId&#34; in response:
224+
telemetry_id = response[&#34;telemetryId&#34;]
230225

231226
number_of_users = await Supertokens.get_instance().get_user_count(
232227
include_recipe_ids=None
@@ -238,7 +233,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
238233

239234
apiDomain, websiteDomain, appName = (
240235
api_options.app_info.api_domain,
241-
api_options.app_info.website_domain,
236+
api_options.app_info.get_origin(api_options.request, {}),
242237
api_options.app_info.app_name,
243238
)
244239

html/supertokens_python/recipe/dashboard/recipe.html

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,11 @@ <h1 class="title">Module <code>supertokens_python.recipe.dashboard.recipe</code>
372372
return None
373373

374374
async def handle_error(
375-
self, request: BaseRequest, err: SuperTokensError, response: BaseResponse
375+
self,
376+
request: BaseRequest,
377+
err: SuperTokensError,
378+
response: BaseResponse,
379+
user_context: Dict[str, Any],
376380
) -&gt; BaseResponse:
377381
raise err
378382

@@ -704,7 +708,11 @@ <h2 class="section-title" id="header-classes">Classes</h2>
704708
return None
705709

706710
async def handle_error(
707-
self, request: BaseRequest, err: SuperTokensError, response: BaseResponse
711+
self,
712+
request: BaseRequest,
713+
err: SuperTokensError,
714+
response: BaseResponse,
715+
user_context: Dict[str, Any],
708716
) -&gt; BaseResponse:
709717
raise err
710718

@@ -1101,7 +1109,7 @@ <h3>Methods</h3>
11011109
</details>
11021110
</dd>
11031111
<dt id="supertokens_python.recipe.dashboard.recipe.DashboardRecipe.handle_error"><code class="name flex">
1104-
<span>async def <span class="ident">handle_error</span></span>(<span>self, request: BaseRequest, err: SuperTokensError, response: BaseResponse) ‑> BaseResponse</span>
1112+
<span>async def <span class="ident">handle_error</span></span>(<span>self, request: BaseRequest, err: SuperTokensError, response: BaseResponse, user_context: Dict[str, Any]) ‑> BaseResponse</span>
11051113
</code></dt>
11061114
<dd>
11071115
<div class="desc"></div>
@@ -1110,7 +1118,11 @@ <h3>Methods</h3>
11101118
<span>Expand source code</span>
11111119
</summary>
11121120
<pre><code class="python">async def handle_error(
1113-
self, request: BaseRequest, err: SuperTokensError, response: BaseResponse
1121+
self,
1122+
request: BaseRequest,
1123+
err: SuperTokensError,
1124+
response: BaseResponse,
1125+
user_context: Dict[str, Any],
11141126
) -&gt; BaseResponse:
11151127
raise err</code></pre>
11161128
</details>

0 commit comments

Comments
 (0)