From c89c3443a8bb677316b85786c09c4750daf108de Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Fri, 13 Dec 2013 14:37:15 -0500 Subject: [PATCH] Support api_key as well as api-key in authenticated_api_view. All of our other API arguments use "_" as the delimiter, so we're migrating this to do that as well (except for the legacy send_message usage, which we're just hoping will eventually shrink to nothing). (imported from commit 40964cc08e0f94ba439a61e4f68ed500f74a554f) --- zerver/decorator.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/zerver/decorator.py b/zerver/decorator.py index e7efddbbf1..5344881d89 100644 --- a/zerver/decorator.py +++ b/zerver/decorator.py @@ -169,8 +169,13 @@ def authenticated_api_view(view_func): @require_post @has_request_variables @wraps(view_func) - def _wrapped_view_func(request, email=REQ, api_key=REQ('api-key'), + def _wrapped_view_func(request, email=REQ, api_key=REQ('api_key', default=None), + api_key_legacy=REQ('api-key', default=None), *args, **kwargs): + if not api_key and not api_key_legacy: + raise RequestVariableMissingError("api_key") + elif not api_key: + api_key = api_key_legacy user_profile = validate_api_key(email, api_key) request.user = user_profile request._email = user_profile.email