From f3d19ad9f45d2956bb2be4b5c2390fbbedbd95c4 Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Fri, 12 Apr 2024 10:39:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=80=90Lark=E3=80=91=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E4=B8=80=E4=BA=9B=E6=8A=A5=E9=94=99=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E4=BC=98=E5=8C=96=20(#13004)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: feng <1304903146@qq.com> --- apps/authentication/views/base.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/authentication/views/base.py b/apps/authentication/views/base.py index 598ec9a0d..8146e1cd2 100644 --- a/apps/authentication/views/base.py +++ b/apps/authentication/views/base.py @@ -1,8 +1,8 @@ from functools import lru_cache from django.conf import settings -from django.db.utils import IntegrityError from django.contrib.auth import logout as auth_logout +from django.db.utils import IntegrityError from django.utils.module_loading import import_string from django.utils.translation import gettext_lazy as _ from django.views import View @@ -12,8 +12,8 @@ from authentication import errors from authentication.mixins import AuthMixin from authentication.notifications import OAuthBindMessage from common.utils import get_logger -from common.utils.django import reverse, get_object_or_none from common.utils.common import get_request_ip +from common.utils.django import reverse, get_object_or_none from users.models import User from users.signal_handlers import check_only_allow_exist_user_auth from .mixins import FlashMessageMixin @@ -83,7 +83,15 @@ class BaseLoginCallbackView(AuthMixin, FlashMessageMixin, IMClientMixin, View): if not self.verify_state(): return self.get_verify_state_failed_response(redirect_url) - user_id, other_info = self.client.get_user_id_by_code(code) + try: + user_id, other_info = self.client.get_user_id_by_code(code) + except Exception: + response = self.get_failed_response( + login_url, title=self.msg_client_err, + msg=self.msg_not_found_user_from_client_err + ) + return response + if not user_id: # 正常流程不会出这个错误,hack 行为 err = self.msg_not_found_user_from_client_err