mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
backends: Fix type errors.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit ec3d187659
)
This commit is contained in:
committed by
Tim Abbott
parent
4455ddd513
commit
224e58a2ac
@@ -3292,7 +3292,6 @@ class SAMLAuthBackendTest(SocialAuthBase):
|
||||
|
||||
|
||||
class AppleAuthMixin:
|
||||
BACKEND_CLASS = AppleAuthBackend
|
||||
CLIENT_KEY_SETTING = "SOCIAL_AUTH_APPLE_KEY"
|
||||
AUTHORIZATION_URL = "https://appleid.apple.com/auth/authorize"
|
||||
ACCESS_TOKEN_URL = "https://appleid.apple.com/auth/token"
|
||||
@@ -3329,6 +3328,7 @@ class AppleAuthMixin:
|
||||
|
||||
|
||||
class AppleIdAuthBackendTest(AppleAuthMixin, SocialAuthBase):
|
||||
BACKEND_CLASS = AppleAuthBackend
|
||||
LOGIN_URL = "/accounts/login/social/apple"
|
||||
SIGNUP_URL = "/accounts/register/social/apple"
|
||||
|
||||
@@ -3462,6 +3462,7 @@ class AppleIdAuthBackendTest(AppleAuthMixin, SocialAuthBase):
|
||||
|
||||
|
||||
class AppleAuthBackendNativeFlowTest(AppleAuthMixin, SocialAuthBase):
|
||||
BACKEND_CLASS = AppleAuthBackend
|
||||
SIGNUP_URL = "/complete/apple/"
|
||||
LOGIN_URL = "/complete/apple/"
|
||||
|
||||
|
@@ -1630,7 +1630,7 @@ def redirect_deactivated_user_to_login(realm: Realm, email: str) -> HttpResponse
|
||||
|
||||
|
||||
def social_associate_user_helper(
|
||||
backend: BaseAuth, return_data: dict[str, Any], *args: Any, **kwargs: Any
|
||||
backend: "SocialAuthMixin", return_data: dict[str, Any], *args: Any, **kwargs: Any
|
||||
) -> HttpResponse | UserProfile | None:
|
||||
"""Responsible for doing the Zulip account lookup and validation parts
|
||||
of the Zulip social auth pipeline (similar to the authenticate()
|
||||
@@ -1790,6 +1790,7 @@ def social_auth_associate_user(
|
||||
later stages of settings.SOCIAL_AUTH_PIPELINE, such as
|
||||
social_auth_finish, as kwargs.
|
||||
"""
|
||||
assert isinstance(backend, SocialAuthMixin)
|
||||
partial_token = backend.strategy.request_data().get("partial_token")
|
||||
return_data: dict[str, Any] = {}
|
||||
user_profile = social_associate_user_helper(backend, return_data, *args, **kwargs)
|
||||
@@ -2143,15 +2144,15 @@ class GitHubAuthBackend(SocialAuthMixin, GithubOAuth2):
|
||||
**kwargs,
|
||||
)
|
||||
elif team_id is not None:
|
||||
backend = GithubTeamOAuth2(self.strategy, self.redirect_uri)
|
||||
team_backend = GithubTeamOAuth2(self.strategy, self.redirect_uri)
|
||||
try:
|
||||
return backend.user_data(access_token, *args, **kwargs)
|
||||
return team_backend.user_data(access_token, *args, **kwargs)
|
||||
except AuthFailed:
|
||||
return dict(auth_failed_reason="GitHub user is not member of required team")
|
||||
elif org_name is not None:
|
||||
backend = GithubOrganizationOAuth2(self.strategy, self.redirect_uri)
|
||||
organization_backend = GithubOrganizationOAuth2(self.strategy, self.redirect_uri)
|
||||
try:
|
||||
return backend.user_data(access_token, *args, **kwargs)
|
||||
return organization_backend.user_data(access_token, *args, **kwargs)
|
||||
except AuthFailed:
|
||||
return dict(auth_failed_reason="GitHub user is not member of required organization")
|
||||
|
||||
|
Reference in New Issue
Block a user