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 }