Skip to content

Commit

Permalink
feat: improve org and app owner handling
Browse files Browse the repository at this point in the history
  • Loading branch information
hsluoyz committed Mar 13, 2024
1 parent 3aafd16 commit a91dcc0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
3 changes: 0 additions & 3 deletions casdoorsdk/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,16 @@ func (c *Client) GetApplication(name string) (*Application, error) {
}

func (c *Client) AddApplication(application *Application) (bool, error) {
application.Owner = "admin"
_, affected, err := c.modifyApplication("add-application", application, nil)
return affected, err
}

func (c *Client) DeleteApplication(application *Application) (bool, error) {
application.Owner = "admin"
_, affected, err := c.modifyApplication("delete-application", application, nil)
return affected, err
}

func (c *Client) UpdateApplication(application *Application) (bool, error) {
application.Owner = "admin"
_, affected, err := c.modifyApplication("update-application", application, nil)
return affected, err
}
3 changes: 0 additions & 3 deletions casdoorsdk/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,16 @@ func (c *Client) GetOrganizationNames() ([]*Organization, error) {
}

func (c *Client) AddOrganization(organization *Organization) (bool, error) {
organization.Owner = "admin"
_, affected, err := c.modifyOrganization("add-organization", organization, nil)
return affected, err
}

func (c *Client) DeleteOrganization(organization *Organization) (bool, error) {
organization.Owner = "admin"
_, affected, err := c.modifyOrganization("delete-organization", organization, nil)
return affected, err
}

func (c *Client) UpdateOrganization(organization *Organization) (bool, error) {
organization.Owner = "admin"
_, affected, err := c.modifyOrganization("update-organization", organization, nil)
return affected, err
}
8 changes: 4 additions & 4 deletions casdoorsdk/util_modify.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ func (c *Client) modifyOrganization(action string, organization *Organization, c
queryMap["columns"] = strings.Join(columns, ",")
}

// organization.Owner = c.OrganizationName
organization.Owner = "admin"

postBytes, err := json.Marshal(organization)
if err != nil {
return nil, false, err
Expand All @@ -56,9 +57,8 @@ func (c *Client) modifyApplication(action string, application *Application, colu
queryMap["columns"] = strings.Join(columns, ",")
}

if application.Owner == "" {
application.Owner = "admin"
}
application.Owner = "admin"

postBytes, err := json.Marshal(application)
if err != nil {
return nil, false, err
Expand Down

0 comments on commit a91dcc0

Please sign in to comment.