Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
2fa: Rename zulip_otp_required for clarity.
Zixuan James Li74f59bd8d011
diff --git a/zerver/decorator.py b/zerver/decorator.pyindex b837ffbe750..a7c4bc02439 100644--- a/zerver/decorator.py+++ b/zerver/decorator.py@@ -528,7 +528,7 @@ def zulip_login_required(login_url=login_url,redirect_field_name=redirect_field_name,)(- zulip_otp_required(+ zulip_otp_required_if_logged_in(redirect_field_name=redirect_field_name,login_url=login_url,)(add_logging_data(function))@@ -548,7 +548,7 @@ def web_public_view(This wrapper adds client info for unauthenticated users butforces authenticated users to go through 2fa."""- actual_decorator = lambda view_func: zulip_otp_required(+ actual_decorator = lambda view_func: zulip_otp_required_if_logged_in(redirect_field_name=redirect_field_name, login_url=login_url)(add_logging_data(view_func))@@ -1021,7 +1021,7 @@ def return_success_on_head_request(view_func: ViewFuncT) -> ViewFuncT:return cast(ViewFuncT, _wrapped_view_func) # https://github.com/python/mypy/issues/1927-def zulip_otp_required(+def zulip_otp_required_if_logged_in(redirect_field_name: str = "next",login_url: str = settings.HOME_NOT_LOGGED_IN,) -> Callable[[ViewFuncT], ViewFuncT]:@@ -1033,7 +1033,7 @@ def zulip_otp_required(Similar to :func:`~django.contrib.auth.decorators.login_required`, butrequires the user to be :term:`verified`. By default, this redirects users- to :setting:`OTP_LOGIN_URL`.+ to :setting:`OTP_LOGIN_URL`. Returns True if the user is not authenticated."""def test(user: Union[UserProfile, AnonymousUser]) -> bool:diff --git a/zerver/tests/test_decorators.py b/zerver/tests/test_decorators.pyindex 6d64a9946ae..1c59a2f29c4 100644--- a/zerver/tests/test_decorators.py+++ b/zerver/tests/test_decorators.py@@ -34,7 +34,7 @@ from zerver.decorator import (validate_api_key,webhook_view,zulip_login_required,- zulip_otp_required,+ zulip_otp_required_if_logged_in,)from zerver.forms import OurAuthenticationFormfrom zerver.lib.cache import dict_to_items_tuple, ignore_unhashable_lru_cache, items_tuple_to_dict@@ -1902,7 +1902,7 @@ class TestZulipLoginRequiredDecorator(ZulipTestCase):self.assertEqual(response.content.decode(), "Success")def test_otp_not_authenticated(self) -> None:- @zulip_otp_required()+ @zulip_otp_required_if_logged_in()def test_view(request: HttpRequest) -> HttpResponse:return HttpResponse("Success")