diff options
| author | altaf-creator <dev@altafcreator.com> | 2025-12-02 16:19:10 +0700 |
|---|---|---|
| committer | altaf-creator <dev@altafcreator.com> | 2025-12-02 16:19:10 +0700 |
| commit | b8155a7854182bbf1bf750226bb62fc38b6bbcaf (patch) | |
| tree | e3d045a02b815f64d5582e5485b747b9e3c7c5db /backend | |
| parent | a4541c9585f926aeb07ab390a8e40cead1eed817 (diff) | |
API /info use cookie
Diffstat (limited to 'backend')
| -rw-r--r-- | backend/main.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/backend/main.py b/backend/main.py index 9b4ac1c..20078d3 100644 --- a/backend/main.py +++ b/backend/main.py @@ -386,8 +386,10 @@ def finish_laundry(data: FinishRequestData, response: fastapi.Response, session_ # --- get information from uri search query @app.post("/info") def uri_to_information(data: InformationRequestData, response: fastapi.Response, auth_block: Annotated[str | None, fastapi.Cookie()] = None): + info = None try: - info = URI_TO_MACHINES[data.machine_id] + if data.machine_id: + info = URI_TO_MACHINES[data.machine_id] except KeyError: response.status_code = fastapi.status.HTTP_404_NOT_FOUND return "INVALID machine ID/URI" @@ -396,6 +398,9 @@ def uri_to_information(data: InformationRequestData, response: fastapi.Response, if auth_block != info[0]: response.status_code = fastapi.status.HTTP_403_FORBIDDEN return "UNAUTHORISED to view information" + if not info: + info = [auth_block, None] + else: authenticate_block(response, block=info[0]) |
