From 237b4a82c9b8b8dae63f59c5895ad71a4e015f83 Mon Sep 17 00:00:00 2001 From: wangruidong <940853815@qq.com> Date: Mon, 1 Jul 2024 17:50:35 +0800 Subject: [PATCH] fix: handle 500 error when re-binding DingTalk user to another user --- apps/authentication/views/dingtalk.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/apps/authentication/views/dingtalk.py b/apps/authentication/views/dingtalk.py index 8e76795cb..650bfe9c8 100644 --- a/apps/authentication/views/dingtalk.py +++ b/apps/authentication/views/dingtalk.py @@ -151,11 +151,9 @@ class DingTalkQRBindCallbackView(DingTalkQRMixin, View): user.dingtalk_id = userid user.save() except IntegrityError as e: - if e.args[0] == 1062: - msg = _('The DingTalk is already bound to another user') - response = self.get_failed_response(redirect_url, msg, msg) - return response - raise e + msg = _('The DingTalk is already bound to another user') + response = self.get_failed_response(redirect_url, msg, msg) + return response ip = get_request_ip(request) OAuthBindMessage(user, ip, _('DingTalk'), user_id).publish_async()