Browse Source

兼容两套认证系统

pull/53/head
JeshuaRen 4 months ago
parent
commit
7907148706
2 changed files with 8 additions and 3 deletions
  1. +1
    -1
      sdks/sso/client.go
  2. +7
    -2
      sdks/sso/sso.go

+ 1
- 1
sdks/sso/client.go View File

@@ -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"`
}


+ 7
- 2
sdks/sso/sso.go View File

@@ -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
}



Loading…
Cancel
Save