Skip to content

Commit

Permalink
fix(bkuser): rasie exception when bk_token is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
nannan00 committed Mar 20, 2024
1 parent d0cd2b9 commit 21e79e4
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/bk-user/bkuser/component/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,26 @@ def _call_login_api(http_func, url_path, **kwargs):
f"error={resp_data['error']}"
)

return resp_data["data"]
code = resp_data.get("bk_error_code", -1)
message = resp_data.get("bk_error_msg", "unknown")
if code == 0:
return resp_data["data"]

logger.error(
"login api error! %s %s, kwargs: %s, request_id: %s, code: %s, message: %s",
http_func.__name__,
url,
kwargs,
request_id,
code,
message,
)

raise error_codes.REMOTE_REQUEST_ERROR.format(
f"request login error! "
f"Request=[{http_func.__name__} {urlparse(url).path} request_id={request_id}] "
f"Response[code={code}, message={message}]"
)


def verify_bk_token(bk_token: str):
Expand Down

0 comments on commit 21e79e4

Please sign in to comment.