decorator: Fix check for incoming webhook bots and move later

The check itself was correct, but the error message was in fact the
opposite of what this check is for.  In other words, the only things
these users can do is post messages, and the error message when you
tried to do something else was to tell you that the user can't post
messages.
This commit is contained in:
Tim Abbott 2017-08-14 15:44:34 -07:00
parent 3c37795675
commit 5ebe507c9b
1 changed files with 3 additions and 3 deletions

View File

@ -206,9 +206,6 @@ def validate_api_key(request, role, api_key, is_webhook=False):
profile = cast(UserProfile, profile) # is UserProfile
if not profile.is_active:
raise JsonableError(_("Account not active"))
if profile.is_incoming_webhook and not is_webhook:
raise JsonableError(_("Account is not valid to post webhook messages"))
if profile.realm.deactivated:
raise JsonableError(_("Realm for account has been deactivated"))
@ -221,6 +218,9 @@ def validate_api_key(request, role, api_key, is_webhook=False):
profile.email, get_subdomain(request)))
raise JsonableError(_("Account is not associated with this subdomain"))
if profile.is_incoming_webhook and not is_webhook:
raise JsonableError(_("This API is not available to incoming webhook bots."))
return profile
def access_user_by_api_key(request, api_key):