Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
decorator: Add an isinstance check for otp auth test function.
Zixuan James Li5bdf49c0050b
diff --git a/zerver/decorator.py b/zerver/decorator.pyindex f0b87065053..8b826c61dee 100644--- a/zerver/decorator.py+++ b/zerver/decorator.py@@ -11,7 +11,7 @@ from django.conf import settingsfrom django.contrib.auth import REDIRECT_FIELD_NAMEfrom django.contrib.auth import login as django_loginfrom django.contrib.auth.decorators import user_passes_test as django_user_passes_test-from django.contrib.auth.models import AnonymousUser+from django.contrib.auth.models import AbstractBaseUser, AnonymousUserfrom django.contrib.auth.views import redirect_to_loginfrom django.http import HttpRequest, HttpResponse, HttpResponseRedirect, QueryDictfrom django.http.multipartparser import MultiPartParser@@ -1004,7 +1004,7 @@ def zulip_otp_required_if_logged_in(to :setting:`OTP_LOGIN_URL`. Returns True if the user is not authenticated."""- def test(user: Union[UserProfile, AnonymousUser]) -> bool:+ def test(user: Union[AbstractBaseUser, AnonymousUser]) -> bool:""":if_configured: If ``True``, an authenticated user with no confirmedOTP devices will be allowed. Also, non-authenticated users will be@@ -1020,6 +1020,7 @@ def zulip_otp_required_if_logged_in(if not user.is_authenticated:return True+ assert isinstance(user, UserProfile)# User has completed 2FA verificationif is_2fa_verified(user):return True