From fb62fa870a0bc435ef8d9478022dd668d8e1beb6 Mon Sep 17 00:00:00 2001 From: Bai Date: Thu, 26 Mar 2026 18:42:47 +0800 Subject: [PATCH] perf: modify custom_sso.py --- apps/authentication/api/custom_sso.py | 4 +++- apps/common/jdmc.py | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/authentication/api/custom_sso.py b/apps/authentication/api/custom_sso.py index eeff4fd9f..196a34135 100644 --- a/apps/authentication/api/custom_sso.py +++ b/apps/authentication/api/custom_sso.py @@ -64,7 +64,9 @@ class CustomSSOLoginAPIView(AuthMixin, RetrieveAPIView): def authenticate(self, **query_params): try: - userinfo: dict = custom_sso_authenticate_method(**query_params) + userinfo, error = custom_sso_authenticate_method(**query_params) + if error: + return None, error self.next_url = userinfo.get('next_url', '/') except Exception as e: error = f'Custom SSO authenticate error: {e}' diff --git a/apps/common/jdmc.py b/apps/common/jdmc.py index 0538338b8..0609d62e0 100644 --- a/apps/common/jdmc.py +++ b/apps/common/jdmc.py @@ -1,13 +1,14 @@ from django.conf import settings +from pydantic import json import requests_unixsocket __all__ = ['request_jdmc'] -def request_jdmc(method='GET', path='', data=None, timeout=(5, 60)): +def request_jdmc(method='GET', path='', timeout=(5, 60), **kwargs): ''' path: JDMC API path, e.g. /jdmc/api/v1/apps/license ''' url = settings.JDMC_BASE_URL + path with requests_unixsocket.Session() as session: - response = session.request(method, url, data=data, timeout=timeout) + response = session.request(method, url, timeout=timeout, **kwargs) return response