@@ -41,6 +41,8 @@ <h1 class="title">Module <code>supertokens_python.recipe.dashboard.api</code></h
4141# under the License.
4242from .api_key_protector import api_key_protector
4343from .dashboard import handle_dashboard_api
44+ from .signin import handle_emailpassword_signin_api
45+ from .signout import handle_emailpassword_signout_api
4446from .userdetails.user_delete import handle_user_delete
4547from .userdetails.user_email_verify_get import handle_user_email_verify_get
4648from .userdetails.user_email_verify_put import handle_user_email_verify_put
@@ -73,6 +75,8 @@ <h1 class="title">Module <code>supertokens_python.recipe.dashboard.api</code></h
7375 "handle_user_sessions_post",
7476 "handle_user_password_put",
7577 "handle_email_verify_token_post",
78+ "handle_emailpassword_signin_api",
79+ "handle_emailpassword_signout_api",
7680]</ code > </ pre >
7781</ details >
7882</ section >
@@ -87,6 +91,14 @@ <h2 class="section-title" id="header-submodules">Sub-modules</h2>
8791< dd >
8892< div class ="desc "> </ div >
8993</ dd >
94+ < dt > < code class ="name "> < a title ="supertokens_python.recipe.dashboard.api.signin " href ="signin.html "> supertokens_python.recipe.dashboard.api.signin</ a > </ code > </ dt >
95+ < dd >
96+ < div class ="desc "> </ div >
97+ </ dd >
98+ < dt > < code class ="name "> < a title ="supertokens_python.recipe.dashboard.api.signout " href ="signout.html "> supertokens_python.recipe.dashboard.api.signout</ a > </ code > </ dt >
99+ < dd >
100+ < div class ="desc "> </ div >
101+ </ dd >
90102< dt > < code class ="name "> < a title ="supertokens_python.recipe.dashboard.api.userdetails " href ="userdetails/index.html "> supertokens_python.recipe.dashboard.api.userdetails</ a > </ code > </ dt >
91103< dd >
92104< div class ="desc "> </ div >
@@ -214,6 +226,74 @@ <h2 class="section-title" id="header-functions">Functions</h2>
214226 return UserEmailVerifyTokenPostAPIOkResponse()</ code > </ pre >
215227</ details >
216228</ dd >
229+ < dt id ="supertokens_python.recipe.dashboard.api.handle_emailpassword_signin_api "> < code class ="name flex ">
230+ < span > async def < span class ="ident "> handle_emailpassword_signin_api</ span > </ span > (< span > _: APIInterface, api_options: APIOptions)</ span >
231+ </ code > </ dt >
232+ < dd >
233+ < div class ="desc "> </ div >
234+ < details class ="source ">
235+ < summary >
236+ < span > Expand source code</ span >
237+ </ summary >
238+ < pre > < code class ="python "> async def handle_emailpassword_signin_api(_: APIInterface, api_options: APIOptions):
239+ body = await api_options.request.json()
240+ if body is None:
241+ raise_bad_input_exception("Please send body")
242+ email = body.get("email")
243+ password = body.get("password")
244+
245+ if email is None or not isinstance(email, str):
246+ raise_bad_input_exception("Missing required parameter 'email'")
247+ if password is None or not isinstance(password, str):
248+ raise_bad_input_exception("Missing required parameter 'password'")
249+ response = await Querier.get_instance().send_post_request(
250+ NormalisedURLPath("/recipe/dashboard/signin"),
251+ {"email": email, "password": password},
252+ )
253+
254+ if "status" in response and response["status"] == "OK":
255+ return send_200_response(
256+ {"status": "OK", "sessionId": response["sessionId"]}, api_options.response
257+ )
258+ if "status" in response and response["status"] == "INVALID_CREDENTIALS_ERROR":
259+ return send_200_response(
260+ {"status": "INVALID_CREDENTIALS_ERROR"},
261+ api_options.response,
262+ )
263+ if "status" in response and response["status"] == "USER_SUSPENDED_ERROR":
264+ return send_200_response(
265+ {"status": "USER_SUSPENDED_ERROR", "message": response["message"]},
266+ api_options.response,
267+ )</ code > </ pre >
268+ </ details >
269+ </ dd >
270+ < dt id ="supertokens_python.recipe.dashboard.api.handle_emailpassword_signout_api "> < code class ="name flex ">
271+ < span > async def < span class ="ident "> handle_emailpassword_signout_api</ span > </ span > (< span > _: APIInterface, api_options: APIOptions) ‑> SignOutOK</ span >
272+ </ code > </ dt >
273+ < dd >
274+ < div class ="desc "> </ div >
275+ < details class ="source ">
276+ < summary >
277+ < span > Expand source code</ span >
278+ </ summary >
279+ < pre > < code class ="python "> async def handle_emailpassword_signout_api(
280+ _: APIInterface, api_options: APIOptions
281+ ) -> SignOutOK:
282+ if api_options.config.auth_mode == "api-key":
283+ return SignOutOK()
284+ session_id_form_auth_header = api_options.request.get_header("authorization")
285+ if not session_id_form_auth_header:
286+ return raise_bad_input_exception(
287+ "Neither 'API Key' nor 'Authorization' header was found"
288+ )
289+ session_id_form_auth_header = session_id_form_auth_header.split()[1]
290+ await Querier.get_instance().send_delete_request(
291+ NormalisedURLPath("/recipe/dashboard/session"),
292+ {"sessionId": session_id_form_auth_header},
293+ )
294+ return SignOutOK()</ code > </ pre >
295+ </ details >
296+ </ dd >
217297< dt id ="supertokens_python.recipe.dashboard.api.handle_metadata_get "> < code class ="name flex ">
218298< span > async def < span class ="ident "> handle_metadata_get</ span > </ span > (< span > _api_interface: < a title ="supertokens_python.recipe.dashboard.interfaces.APIInterface " href ="../interfaces.html#supertokens_python.recipe.dashboard.interfaces.APIInterface "> APIInterface</ a > , api_options: < a title ="supertokens_python.recipe.dashboard.interfaces.APIOptions " href ="../interfaces.html#supertokens_python.recipe.dashboard.interfaces.APIOptions "> APIOptions</ a > ) ‑> Union[< a title ="supertokens_python.recipe.dashboard.interfaces.UserMetadataGetAPIOkResponse " href ="../interfaces.html#supertokens_python.recipe.dashboard.interfaces.UserMetadataGetAPIOkResponse "> UserMetadataGetAPIOkResponse</ a > , < a title ="supertokens_python.recipe.dashboard.interfaces.FeatureNotEnabledError " href ="../interfaces.html#supertokens_python.recipe.dashboard.interfaces.FeatureNotEnabledError "> FeatureNotEnabledError</ a > ]</ span >
219299</ code > </ dt >
@@ -824,7 +904,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
824904</ details >
825905</ dd >
826906< dt id ="supertokens_python.recipe.dashboard.api.handle_validate_key_api "> < code class ="name flex ">
827- < span > async def < span class ="ident "> handle_validate_key_api</ span > </ span > (< span > api_implementation : APIInterface, api_options: APIOptions)</ span >
907+ < span > async def < span class ="ident "> handle_validate_key_api</ span > </ span > (< span > _api_implementation : APIInterface, api_options: APIOptions)</ span >
828908</ code > </ dt >
829909< dd >
830910< div class ="desc "> </ div >
@@ -833,21 +913,14 @@ <h2 class="section-title" id="header-functions">Functions</h2>
833913< span > Expand source code</ span >
834914</ summary >
835915< pre > < code class ="python "> async def handle_validate_key_api(
836- api_implementation : APIInterface, api_options: APIOptions
916+ _api_implementation : APIInterface, api_options: APIOptions
837917):
838- _ = api_implementation
839918
840- should_allow_accesss = await api_options.recipe_implementation.should_allow_access(
841- api_options.request,
842- api_options.config,
843- default_user_context(api_options.request),
844- )
845- if should_allow_accesss is False:
846- return send_non_200_response_with_message(
847- "Unauthorized access", 401, api_options.response
848- )
919+ is_valid_key = validate_api_key(api_options.request, api_options.config)
849920
850- return send_200_response({"status": "OK"}, api_options.response)</ code > </ pre >
921+ if is_valid_key:
922+ return send_200_response({"status": "OK"}, api_options.response)
923+ return send_non_200_response_with_message("Unauthorised", 401, api_options.response)</ code > </ pre >
851924</ details >
852925</ dd >
853926</ dl >
@@ -870,6 +943,8 @@ <h2>Index</h2>
870943< ul >
871944< li > < code > < a title ="supertokens_python.recipe.dashboard.api.dashboard " href ="dashboard.html "> supertokens_python.recipe.dashboard.api.dashboard</ a > </ code > </ li >
872945< li > < code > < a title ="supertokens_python.recipe.dashboard.api.implementation " href ="implementation.html "> supertokens_python.recipe.dashboard.api.implementation</ a > </ code > </ li >
946+ < li > < code > < a title ="supertokens_python.recipe.dashboard.api.signin " href ="signin.html "> supertokens_python.recipe.dashboard.api.signin</ a > </ code > </ li >
947+ < li > < code > < a title ="supertokens_python.recipe.dashboard.api.signout " href ="signout.html "> supertokens_python.recipe.dashboard.api.signout</ a > </ code > </ li >
873948< li > < code > < a title ="supertokens_python.recipe.dashboard.api.userdetails " href ="userdetails/index.html "> supertokens_python.recipe.dashboard.api.userdetails</ a > </ code > </ li >
874949< li > < code > < a title ="supertokens_python.recipe.dashboard.api.users_count_get " href ="users_count_get.html "> supertokens_python.recipe.dashboard.api.users_count_get</ a > </ code > </ li >
875950< li > < code > < a title ="supertokens_python.recipe.dashboard.api.users_get " href ="users_get.html "> supertokens_python.recipe.dashboard.api.users_get</ a > </ code > </ li >
@@ -881,6 +956,8 @@ <h2>Index</h2>
881956< li > < code > < a title ="supertokens_python.recipe.dashboard.api.api_key_protector " href ="#supertokens_python.recipe.dashboard.api.api_key_protector "> api_key_protector</ a > </ code > </ li >
882957< li > < code > < a title ="supertokens_python.recipe.dashboard.api.handle_dashboard_api " href ="#supertokens_python.recipe.dashboard.api.handle_dashboard_api "> handle_dashboard_api</ a > </ code > </ li >
883958< li > < code > < a title ="supertokens_python.recipe.dashboard.api.handle_email_verify_token_post " href ="#supertokens_python.recipe.dashboard.api.handle_email_verify_token_post "> handle_email_verify_token_post</ a > </ code > </ li >
959+ < li > < code > < a title ="supertokens_python.recipe.dashboard.api.handle_emailpassword_signin_api " href ="#supertokens_python.recipe.dashboard.api.handle_emailpassword_signin_api "> handle_emailpassword_signin_api</ a > </ code > </ li >
960+ < li > < code > < a title ="supertokens_python.recipe.dashboard.api.handle_emailpassword_signout_api " href ="#supertokens_python.recipe.dashboard.api.handle_emailpassword_signout_api "> handle_emailpassword_signout_api</ a > </ code > </ li >
884961< li > < code > < a title ="supertokens_python.recipe.dashboard.api.handle_metadata_get " href ="#supertokens_python.recipe.dashboard.api.handle_metadata_get "> handle_metadata_get</ a > </ code > </ li >
885962< li > < code > < a title ="supertokens_python.recipe.dashboard.api.handle_metadata_put " href ="#supertokens_python.recipe.dashboard.api.handle_metadata_put "> handle_metadata_put</ a > </ code > </ li >
886963< li > < code > < a title ="supertokens_python.recipe.dashboard.api.handle_sessions_get " href ="#supertokens_python.recipe.dashboard.api.handle_sessions_get "> handle_sessions_get</ a > </ code > </ li >
0 commit comments