From d8927294f48c51a626fff565b7caa9d09715b2f8 Mon Sep 17 00:00:00 2001 From: justcool393 Date: Sun, 9 Oct 2022 00:31:56 -0700 Subject: [PATCH] fix 500 when no state is passed in to discord redirect function --- files/routes/discord.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/files/routes/discord.py b/files/routes/discord.py index befe4c569..b9d8c353f 100644 --- a/files/routes/discord.py +++ b/files/routes/discord.py @@ -23,16 +23,17 @@ def join_discord(v): @app.get("/discord_redirect") @auth_required def discord_redirect(v): + now = int(time.time()) + state = request.values.get('state') + if not state or not '.' in state: abort(400) + state = state.split('.') + timestamp= state[0] + state= state[1] - - now=int(time.time()) - state=request.values.get('state','').split('.') - - timestamp=state[0] - - state=state[1] - - if int(timestamp) < now-600: + try: + if int(timestamp) < now-600: + abort(400) + except: abort(400) if not validate_hash(f"{timestamp}+{v.id}+discord", state):