From ddcf719cf6597f4a76d01eb8d25fff2c3e3460bd Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Tue, 21 Aug 2018 00:43:23 +0000 Subject: [PATCH] Valid session required to get all them users --- webapp/titanembeds/blueprints/api/api.py | 3 +++ webapp/titanembeds/decorators.py | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/webapp/titanembeds/blueprints/api/api.py b/webapp/titanembeds/blueprints/api/api.py index def41aa..d13c8a0 100644 --- a/webapp/titanembeds/blueprints/api/api.py +++ b/webapp/titanembeds/blueprints/api/api.py @@ -503,6 +503,7 @@ def create_authenticated_user(): return response @api.route("/user//") +@abort_if_guild_disabled() def user_info(guild_id, user_id): usr = { "id": None, @@ -534,6 +535,8 @@ def user_info(guild_id, user_id): return jsonify(usr) @api.route("/user/") +@abort_if_guild_disabled() +@valid_session_required(api=True) def list_users(guild_id): all_users = get_all_users(guild_id) return jsonify(all_users) diff --git a/webapp/titanembeds/decorators.py b/webapp/titanembeds/decorators.py index a6ad5f0..830bf9e 100644 --- a/webapp/titanembeds/decorators.py +++ b/webapp/titanembeds/decorators.py @@ -28,11 +28,13 @@ def discord_users_only(api=False): return decorated_function return decorator -def abort_if_guild_disabled(): +def abort_if_guild_disabled(*args): def decorator(f): @wraps(f) def decorated_function(*args, **kwargs): guild_id = request.args.get("guild_id", None) + if not guild_id and len(args) > 0: + guild_id = args[0] if guild_id in list_disabled_guilds(): return ('', 423) return f(*args, **kwargs)