From a9a261634abeb7fde92c038bdcf90de5166adcdc Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Sun, 17 Sep 2017 23:41:08 +0000 Subject: [PATCH] Sanity check in case add member fails --- webapp/titanembeds/blueprints/api/api.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/webapp/titanembeds/blueprints/api/api.py b/webapp/titanembeds/blueprints/api/api.py index 1d3789a..5439061 100644 --- a/webapp/titanembeds/blueprints/api/api.py +++ b/webapp/titanembeds/blueprints/api/api.py @@ -388,7 +388,9 @@ def create_authenticated_user(): abort(404) if not checkUserBanned(guild_id): if not check_user_in_guild(guild_id): - discord_api.add_guild_member(guild_id, session['user_id'], session['user_keys']['access_token']) + add_member = discord_api.add_guild_member(guild_id, session['user_id'], session['user_keys']['access_token']) + if not add_member["success"]: + abort(403) db_user = db.session.query(AuthenticatedUsers).filter(and_(AuthenticatedUsers.guild_id == guild_id, AuthenticatedUsers.client_id == session['user_id'])).first() if not db_user: db_user = AuthenticatedUsers(guild_id, session['user_id'])