From a3b9d71e706b17741af5fd204c13253ffe110b93 Mon Sep 17 00:00:00 2001 From: justcool393 Date: Wed, 5 Oct 2022 20:50:02 -0700 Subject: [PATCH] user badge permissions --- files/helpers/const.py | 1 + files/routes/admin.py | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/files/helpers/const.py b/files/helpers/const.py index df197845a..9d4e1524e 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -130,6 +130,7 @@ PERMS = { # Minimum admin_level to perform action. 'POST_COMMENT_MODERATION': 2, 'GLOBAL_HOLE_MODERATION': 3, 'POST_EDITING': 3, + 'USER_BADGES': 2, 'USER_BAN': 2, 'USER_SHADOWBAN': 2, 'USER_AGENDAPOSTER': 2, diff --git a/files/routes/admin.py b/files/routes/admin.py index 2ccdee9d0..ae72346c4 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -516,7 +516,7 @@ def under_attack(v): return {"error": "Failed to enable under attack mode."}, 400 @app.get("/admin/badge_grant") -@admin_level_required(2) +@admin_level_required(PERMS['USER_BADGES']) def badge_grant_get(v): if not FEATURES['BADGES']: abort(404) @@ -527,7 +527,7 @@ def badge_grant_get(v): @app.post("/admin/badge_grant") @limiter.limit("1/second;30/minute;200/hour;1000/day") -@admin_level_required(2) +@admin_level_required(PERMS['USER_BADGES']) def badge_grant_post(v): if not FEATURES['BADGES']: abort(404) @@ -577,7 +577,7 @@ def badge_grant_post(v): @app.get("/admin/badge_remove") -@admin_level_required(2) +@admin_level_required(PERMS['USER_BADGES']) def badge_remove_get(v): if not FEATURES['BADGES']: abort(404) @@ -589,7 +589,7 @@ def badge_remove_get(v): @app.post("/admin/badge_remove") @limiter.limit("1/second;30/minute;200/hour;1000/day") -@admin_level_required(2) +@admin_level_required(PERMS['USER_BADGES']) def badge_remove_post(v): if not FEATURES['BADGES']: abort(404)