decorator: Simplify invalid API key error messages.

This commit is contained in:
Tim Abbott
2017-08-14 15:38:01 -07:00
parent 928a93bb9a
commit 052e173aae

View File

@@ -195,12 +195,7 @@ def validate_api_key(request, role, api_key, is_webhook=False):
raise JsonableError(_("Invalid user: %s") % (role,))
if api_key != profile.api_key:
if len(api_key) != 32:
reason = _("Incorrect API key length (keys should be 32 "
"characters long) for role '%s'")
else:
reason = _("Invalid API key for role '%s'")
raise JsonableError(reason % (role,))
raise JsonableError(_("Invalid API key"))
# early exit for RemoteZulipServer instances
if settings.ZILENCER_ENABLED and isinstance(profile, RemoteZulipServer):