fix 500 errors

master
Aevann1 2022-07-28 16:23:38 +02:00
parent b8597a1649
commit 07be18cd1b
2 changed files with 9 additions and 4 deletions

View File

@ -1042,12 +1042,14 @@ def ban_user(user_id, v):
if 'reason' in request.values:
if request.values["reason"].startswith("/post/"):
post = int(request.values["reason"].split("/post/")[1].split(None, 1)[0])
try: post = int(request.values["reason"].split("/post/")[1].split(None, 1)[0])
except: abort(400)
post = get_post(post)
post.bannedfor = f'{duration} by @{v.username}'
g.db.add(post)
elif request.values["reason"].startswith("/comment/"):
comment = int(request.values["reason"].split("/comment/")[1].split(None, 1)[0])
try: comment = int(request.values["reason"].split("/comment/")[1].split(None, 1)[0])
except: abort(400)
comment = get_comment(comment)
comment.bannedfor = f'{duration} by @{v.username}'
g.db.add(comment)

View File

@ -121,8 +121,11 @@ def login_post():
elif request.values.get("2fa_token", "x"):
now = int(time.time())
if now - int(request.values.get("time")) > 600:
return redirect('/login')
try:
if now - int(request.values.get("time")) > 600:
return redirect('/login')
except:
abort(400)
formhash = request.values.get("hash")
if not validate_hash(f"{account.id}+{request.values.get('time')}+2fachallenge", formhash):