forked from rDrama/rDrama
fix 500 when no state is passed in to discord redirect function
parent
8ea52ba95c
commit
d8927294f4
|
@ -23,16 +23,17 @@ def join_discord(v):
|
||||||
@app.get("/discord_redirect")
|
@app.get("/discord_redirect")
|
||||||
@auth_required
|
@auth_required
|
||||||
def discord_redirect(v):
|
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]
|
||||||
|
|
||||||
|
try:
|
||||||
now=int(time.time())
|
if int(timestamp) < now-600:
|
||||||
state=request.values.get('state','').split('.')
|
abort(400)
|
||||||
|
except:
|
||||||
timestamp=state[0]
|
|
||||||
|
|
||||||
state=state[1]
|
|
||||||
|
|
||||||
if int(timestamp) < now-600:
|
|
||||||
abort(400)
|
abort(400)
|
||||||
|
|
||||||
if not validate_hash(f"{timestamp}+{v.id}+discord", state):
|
if not validate_hash(f"{timestamp}+{v.id}+discord", state):
|
||||||
|
|
Loading…
Reference in New Issue