fix 500 errors

remotes/1693045480750635534/spooky-22
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 'reason' in request.values:
if request.values["reason"].startswith("/post/"): 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 = get_post(post)
post.bannedfor = f'{duration} by @{v.username}' post.bannedfor = f'{duration} by @{v.username}'
g.db.add(post) g.db.add(post)
elif request.values["reason"].startswith("/comment/"): 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 = get_comment(comment)
comment.bannedfor = f'{duration} by @{v.username}' comment.bannedfor = f'{duration} by @{v.username}'
g.db.add(comment) g.db.add(comment)

View File

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