fix 500 when no state is passed in to discord redirect function

master
justcool393 2022-10-09 00:31:56 -07:00
parent 8ea52ba95c
commit d8927294f4
1 changed files with 10 additions and 9 deletions

View File

@ -23,17 +23,18 @@ def join_discord(v):
@app.get("/discord_redirect")
@auth_required
def discord_redirect(v):
now = int(time.time())
state=request.values.get('state','').split('.')
state = request.values.get('state')
if not state or not '.' in state: abort(400)
state = state.split('.')
timestamp= state[0]
state= state[1]
try:
if int(timestamp) < now-600:
abort(400)
except:
abort(400)
if not validate_hash(f"{timestamp}+{v.id}+discord", state):
abort(400)