Skip to content

Commit

Permalink
Cleanup other instances where orgName was used as teamName
Browse files Browse the repository at this point in the history
  • Loading branch information
frostyfan109 committed Jun 4, 2024
1 parent c6961c3 commit dc67dd1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
"github.com/gorilla/mux"
)

const DEFAULT_TEAM_NAME = "default"

type GiteaAccess struct {
URL string
Username string
Expand Down Expand Up @@ -1967,8 +1969,7 @@ func handleCreateOrg(w http.ResponseWriter, r *http.Request) {

log.Println("Received Org Data:", options)
if err := createOrg(access.URL, access.Username, access.Password, options.OrgName); err == nil {
teamName := "default" // must be less than 30 chars
if err := createTeam(access.URL, access.Username, access.Password, options.OrgName, teamName, "Primary Team for "+options.OrgName); err == nil {
if err := createTeam(access.URL, access.Username, access.Password, options.OrgName, DEFAULT_TEAM_NAME, "Primary Team for "+options.OrgName); err == nil {
w.WriteHeader(http.StatusCreated)
w.Write([]byte("Org created successfully"))
} else {
Expand All @@ -1993,7 +1994,7 @@ func handleOrg(w http.ResponseWriter, r *http.Request) {
}

func getOrgMembers(giteaBaseURL, adminUsername, adminPassword, orgName string) ([]api.User, error) {
teamID, err := getTeamID(giteaBaseURL, adminUsername, adminPassword, orgName, orgName)
teamID, err := getTeamID(giteaBaseURL, adminUsername, adminPassword, orgName, DEFAULT_TEAM_NAME)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -2052,7 +2053,7 @@ func handleAddMember(w http.ResponseWriter, r *http.Request) {
orgName := vars["orgName"]
userName := vars["userName"]

if err := addUserToTeam(access.URL, access.Username, access.Password, orgName, orgName, userName); err == nil {
if err := addUserToTeam(access.URL, access.Username, access.Password, orgName, DEFAULT_TEAM_NAME, userName); err == nil {
// Respond to the client
w.WriteHeader(http.StatusCreated)
w.Write([]byte("User added to organization"))
Expand Down

0 comments on commit dc67dd1

Please sign in to comment.