mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 23:43:43 +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
@@ -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