From f6b354f10d8275bbbaf444bff173bf0b74bfd4b0 Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Wed, 20 Sep 2017 21:20:06 +0000 Subject: [PATCH] Make 422 status when titan failed to add user to guild --- webapp/titanembeds/blueprints/api/api.py | 4 +++- webapp/titanembeds/static/js/embed.js | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/webapp/titanembeds/blueprints/api/api.py b/webapp/titanembeds/blueprints/api/api.py index d43c839..3f8c6a8 100644 --- a/webapp/titanembeds/blueprints/api/api.py +++ b/webapp/titanembeds/blueprints/api/api.py @@ -390,7 +390,9 @@ def create_authenticated_user(): if not check_user_in_guild(guild_id): add_member = discord_api.add_guild_member(guild_id, session['user_id'], session['user_keys']['access_token']) if not add_member["success"]: - abort(403) + response = jsonify(add_member) + response.status_code = 422 + return response 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']) diff --git a/webapp/titanembeds/static/js/embed.js b/webapp/titanembeds/static/js/embed.js index 68e2457..6f80436 100644 --- a/webapp/titanembeds/static/js/embed.js +++ b/webapp/titanembeds/static/js/embed.js @@ -969,6 +969,8 @@ Materialize.toast('Authentication error! You have been banned.', 10000); } else if (data.status == 406) { Materialize.toast('Illegal username provided! Only alphanumeric, spaces, dashes, and underscores allowed in usernames.', 10000); + } else if (data.status == 422) { + Materialize.toast("Attempting to add you into the server has failed. Either you are banned, reached 100 servers in Discord, or something else bad has happened.", 10000); } unlock_login_fields(); setVisitorMode(true);