decorator: Remove authenticated_json_post_view.

It’s effectively a combination of require_post with
authenticated_json_view and has one use.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2020-06-23 18:22:41 -07:00
parent b655029ced
commit dcbc8e66fb
3 changed files with 9 additions and 19 deletions

View File

@@ -324,9 +324,8 @@ preferable from a security perspective, and it is generally a good idea
to make your feature available to other clients, especially the mobile
clients.
These endpoints make use of some older authentication decorators,
`authenticated_json_api_view`, `authenticated_json_post_view`, and
`authenticated_json_view`, so you may see them in the code.
These endpoints make use the older authentication decorator
`authenticated_json_view`, so you may see it in the code.
## Incoming webhook integrations

View File

@@ -672,20 +672,9 @@ def authenticate_log_and_execute_json(request: HttpRequest,
query=view_func.__name__)
return limited_view_func(request, user_profile, *args, **kwargs)
# Checks if the request is a POST request and that the user is logged
# in. If not, return an error (the @login_required behavior of
# redirecting to a login page doesn't make sense for json views)
def authenticated_json_post_view(
view_func: Callable[..., HttpResponse],
) -> Callable[..., HttpResponse]:
@require_post
@has_request_variables
@wraps(view_func)
def _wrapped_view_func(request: HttpRequest,
*args: Any, **kwargs: Any) -> HttpResponse:
return authenticate_log_and_execute_json(request, view_func, *args, **kwargs)
return _wrapped_view_func
# Checks if the user is logged in. If not, return an error (the
# @login_required behavior of redirecting to a login page doesn't make
# sense for json views)
def authenticated_json_view(
view_func: Callable[..., HttpResponse],
skip_rate_limiting: bool = False,

View File

@@ -22,8 +22,9 @@ from django.utils.translation import override as override_language
from django.utils.translation import ugettext as _
from zerver.decorator import (
authenticated_json_post_view,
authenticated_json_view,
require_non_guest_user,
require_post,
require_realm_admin,
)
from zerver.lib.actions import (
@@ -643,7 +644,8 @@ def delete_in_topic(request: HttpRequest, user_profile: UserProfile,
return json_success()
@authenticated_json_post_view
@require_post
@authenticated_json_view
@has_request_variables
def json_stream_exists(request: HttpRequest, user_profile: UserProfile, stream_name: str=REQ("stream"),
autosubscribe: bool=REQ(validator=check_bool, default=False)) -> HttpResponse: