diff --git a/apps/authentication/backends/oidc/views.py b/apps/authentication/backends/oidc/views.py index 613836d84..e108e8d69 100644 --- a/apps/authentication/backends/oidc/views.py +++ b/apps/authentication/backends/oidc/views.py @@ -171,9 +171,10 @@ class OIDCAuthCallbackView(View, FlashMessageMixin): logger.debug(log_prompt.format('Process authenticate')) try: user = auth.authenticate(nonce=nonce, request=request, code_verifier=code_verifier) - except IntegrityError: + except IntegrityError as e: title = _("OpenID Error") msg = _('Please check if a user with the same username or email already exists') + logger.error(e, exc_info=True) response = self.get_failed_response('/', title, msg) return response if user: diff --git a/apps/authentication/backends/saml2/views.py b/apps/authentication/backends/saml2/views.py index ffc5d4dbf..2ea39efd3 100644 --- a/apps/authentication/backends/saml2/views.py +++ b/apps/authentication/backends/saml2/views.py @@ -278,9 +278,10 @@ class Saml2AuthCallbackView(View, PrepareRequestMixin, FlashMessageMixin): saml_user_data = self.get_attributes(saml_instance) try: user = auth.authenticate(request=request, saml_user_data=saml_user_data) - except IntegrityError: + except IntegrityError as e: title = _("SAML2 Error") msg = _('Please check if a user with the same username or email already exists') + logger.error(e, exc_info=True) response = self.get_failed_response('/', title, msg) return response if user and user.is_valid: diff --git a/apps/authentication/views/base.py b/apps/authentication/views/base.py index 8b953706e..93e602934 100644 --- a/apps/authentication/views/base.py +++ b/apps/authentication/views/base.py @@ -150,6 +150,7 @@ class BaseBindCallbackView(FlashMessageMixin, IMClientMixin, View): user.save() except IntegrityError as e: msg = _('The %s is already bound to another user') % self.auth_type_label + logger.error(e, exc_info=True) response = self.get_failed_response(redirect_url, msg, msg) return response diff --git a/apps/authentication/views/dingtalk.py b/apps/authentication/views/dingtalk.py index e45c6951f..a16803455 100644 --- a/apps/authentication/views/dingtalk.py +++ b/apps/authentication/views/dingtalk.py @@ -144,6 +144,7 @@ class DingTalkQRBindCallbackView(DingTalkQRMixin, View): user.save() except IntegrityError as e: msg = _('The DingTalk is already bound to another user') + logger.error(e, exc_info=True) response = self.get_failed_response(redirect_url, msg, msg) return response