Skip to content

Commit

Permalink
feat: fix owner issue in Token APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
hsluoyz committed Mar 8, 2024
1 parent 3d0d3f1 commit 3aafd16
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions casdoorsdk/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type Token struct {

func (c *Client) GetTokens() ([]*Token, error) {
queryMap := map[string]string{
"owner": c.OrganizationName,
"owner": "admin",
}

url := c.GetUrl("get-tokens", queryMap)
Expand All @@ -63,7 +63,7 @@ func (c *Client) GetTokens() ([]*Token, error) {
}

func (c *Client) GetPaginationTokens(p int, pageSize int, queryMap map[string]string) ([]*Token, int, error) {
queryMap["owner"] = c.OrganizationName
queryMap["owner"] = "admin"
queryMap["p"] = strconv.Itoa(p)
queryMap["pageSize"] = strconv.Itoa(pageSize)

Expand All @@ -84,7 +84,7 @@ func (c *Client) GetPaginationTokens(p int, pageSize int, queryMap map[string]st

func (c *Client) GetToken(name string) (*Token, error) {
queryMap := map[string]string{
"id": fmt.Sprintf("%s/%s", c.OrganizationName, name),
"id": fmt.Sprintf("%s/%s", "admin", name),
}

url := c.GetUrl("get-token", queryMap)
Expand Down
11 changes: 6 additions & 5 deletions casdoorsdk/token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ func TestToken(t *testing.T) {

// Add a new object
token := &Token{
Owner: "admin",
Name: name,
CreatedTime: GetCurrentTime(),
Code: "abc",
AccessToken: "123456",
Owner: "admin",
Name: name,
CreatedTime: GetCurrentTime(),
Organization: "casbin",
Code: "abc",
AccessToken: "123456",
}
_, err := AddToken(token)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion casdoorsdk/util_modify.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ func (c *Client) modifyToken(action string, token *Token, columns []string) (*Re
queryMap["columns"] = strings.Join(columns, ",")
}

token.Owner = c.OrganizationName
// token.Owner = c.OrganizationName
postBytes, err := json.Marshal(token)
if err != nil {
return nil, false, err
Expand Down

0 comments on commit 3aafd16

Please sign in to comment.