From 9e05f0a3b54bc87a3041c54b54fe3919c2b2b589 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 13 Jul 2022 23:12:07 +0200 Subject: [PATCH] refactor changelog v2 --- files/routes/posts.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/files/routes/posts.py b/files/routes/posts.py index 89b6dce52..1a4b1712f 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -704,8 +704,12 @@ def submit_post(v, sub=None): return render_template("submit.html", SUBS=SUBS, v=v, error=error, title=title, url=url, body=body), 400 - sub = request.values.get("sub") - if sub: sub = sub.replace('/h/','').replace('s/','') + sub = request.values.get("sub", "").lower().replace('/h/','').strip() + + if sub == 'changelog': + allowed = g.db.query(User.id).filter(User.admin_level > 0).all() + g.db.query(Badge.user_id).filter_by(badge_id=3).all() + allowed = [x[0] for x in allowed] + if v.id not in allowed: return error(f"You don't have sufficient permissions to post in /h/changelog") if sub and sub != 'none': sname = sub.strip().lower()