Fix key check
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Madis Mägi 2023-08-01 23:02:58 +03:00
parent 37027baf3e
commit 0fd17b7cbb

View File

@ -31,7 +31,7 @@ async def setup_db(app, loop):
@app.route("/allowed") @app.route("/allowed")
async def view_doorboy_uids(request): async def view_doorboy_uids(request):
key = request.headers.get("KEY") key = request.headers.get("KEY")
if key not in [DOORBOY_SECRET_FLOOR, DOORBOY_SECRET_WORKSHOP]: if not key or key not in [DOORBOY_SECRET_FLOOR, DOORBOY_SECRET_WORKSHOP]:
return text("how about no") return text("how about no")
if key == DOORBOY_SECRET_FLOOR: if key == DOORBOY_SECRET_FLOOR:
@ -56,7 +56,7 @@ async def view_doorboy_uids(request):
@app.route("/longpoll", stream=True) @app.route("/longpoll", stream=True)
async def view_longpoll(request): async def view_longpoll(request):
response = await request.respond(content_type="text/event-stream") response = await request.respond(content_type="text/event-stream")
if key not in [DOORBOY_SECRET_FLOOR, DOORBOY_SECRET_WORKSHOP]: if not key or key not in [DOORBOY_SECRET_FLOOR, DOORBOY_SECRET_WORKSHOP]:
return text("Invalid token") return text("Invalid token")
await response.send("data: response-generator-started\n\n") await response.send("data: response-generator-started\n\n")