From 790714870605886c8d15312e45231bfab6e78c7e Mon Sep 17 00:00:00 2001 From: JeshuaRen <270813223@qq.com> Date: Tue, 1 Jul 2025 15:53:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E4=B8=A4=E5=A5=97=E8=AE=A4?= =?UTF-8?q?=E8=AF=81=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sdks/sso/client.go | 2 +- sdks/sso/sso.go | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/sdks/sso/client.go b/sdks/sso/client.go index 81eb255..fabef4b 100644 --- a/sdks/sso/client.go +++ b/sdks/sso/client.go @@ -7,7 +7,7 @@ import ( ) type response[T any] struct { - Code string `json:"code"` + Code int `json:"code"` Message string `json:"message"` Data T `json:"data"` } diff --git a/sdks/sso/sso.go b/sdks/sso/sso.go index f266757..ee8f7b5 100644 --- a/sdks/sso/sso.go +++ b/sdks/sso/sso.go @@ -2,7 +2,6 @@ package sso import ( "fmt" - "gitlink.org.cn/cloudream/common/consts/errorcode" "gitlink.org.cn/cloudream/common/utils/http2" "gitlink.org.cn/cloudream/common/utils/serder" "net/url" @@ -14,6 +13,7 @@ type SSOInfoResp struct { Roles []string `json:"roles"` ID string `json:"id"` Username string `json:"username"` + Menus []any `json:"menus"` } func (c *Client) GetSSOInfo(token string) (*SSOInfoResp, error) { @@ -33,6 +33,11 @@ func (c *Client) GetSSOInfo(token string) (*SSOInfoResp, error) { return nil, err } + //all, err := io.ReadAll(resp.Body) + //println("output: ") + //str := string(all) + //println(str) + contType := resp.Header.Get("Content-Type") if strings.Contains(contType, http2.ContentTypeJSON) { var codeResp response[SSOInfoResp] @@ -40,7 +45,7 @@ func (c *Client) GetSSOInfo(token string) (*SSOInfoResp, error) { return nil, fmt.Errorf("parsing response: %w", err) } - if codeResp.Code == errorcode.OK { + if codeResp.Code == ResponseCodeOK { return &codeResp.Data, nil }