diff --git a/backend/go-app/go.mod b/backend/go-app/go.mod index 21dd9dc8..9841d41a 100644 --- a/backend/go-app/go.mod +++ b/backend/go-app/go.mod @@ -22,7 +22,7 @@ require ( github.com/docker/go-units v0.4.0 // indirect github.com/elastic/go-elasticsearch/v7 v7.13.1 // indirect github.com/frikky/kin-openapi v0.39.0 - github.com/frikky/shuffle-shared v0.0.72 + github.com/frikky/shuffle-shared v0.0.74 github.com/fsouza/go-dockerclient v1.7.2 github.com/ghodss/yaml v1.0.0 github.com/go-git/go-billy/v5 v5.0.0 diff --git a/backend/go-app/main.go b/backend/go-app/main.go index 55c5d705..926ea1ec 100644 --- a/backend/go-app/main.go +++ b/backend/go-app/main.go @@ -739,12 +739,15 @@ func handleRegister(resp http.ResponseWriter, request *http.Request) { } } + apikey := "" if count != 0 { if user.Role != "admin" { resp.WriteHeader(401) resp.Write([]byte(`{"success": false, "reason": "Can't register without being admin (2)"}`)) return } + } else { + apikey = uuid.NewV4().String() } // Gets a struct of Username, password @@ -819,7 +822,7 @@ func handleRegister(resp http.ResponseWriter, request *http.Request) { } } - err = createNewUser(data.Username, data.Password, role, "", currentOrg) + err = createNewUser(data.Username, data.Password, role, apikey, currentOrg) if err != nil { log.Printf("[WARNING] Failed registering user: %s", err) resp.WriteHeader(401) @@ -828,7 +831,7 @@ func handleRegister(resp http.ResponseWriter, request *http.Request) { } resp.WriteHeader(200) - resp.Write([]byte(`{"success": true}`)) + resp.Write([]byte(fmt.Sprintf(`{"success": true, "apikey": "%s"}`, apikey))) log.Printf("[INFO] %s Successfully registered.", data.Username) } @@ -4147,12 +4150,12 @@ func runInitEs(ctx context.Context) { r, err := git.Clone(storer, fs, cloneOptions) if err != nil { - log.Printf("Failed loading repo into memory (init): %s", err) + log.Printf("[WARNING] Failed loading repo into memory (init): %s", err) } dir, err := fs.ReadDir("") if err != nil { - log.Printf("Failed reading folder: %s", err) + log.Printf("[WARNING] Failed reading folder (init): %s", err) } _ = r //iterateAppGithubFolders(fs, dir, "", "testing") @@ -5837,6 +5840,7 @@ func initHandlers() { r.HandleFunc("/api/v1/orgs/{orgId}", shuffle.HandleGetOrg).Methods("GET", "OPTIONS") r.HandleFunc("/api/v1/orgs/{orgId}", shuffle.HandleEditOrg).Methods("POST", "OPTIONS") r.HandleFunc("/api/v1/orgs/{orgId}/create_sub_org", shuffle.HandleCreateSubOrg).Methods("POST", "OPTIONS") + r.HandleFunc("/api/v1/orgs/{orgId}/change", shuffle.HandleChangeUserOrg).Methods("POST", "OPTIONS") // Swaps to the org // This is a new API that validates if a key has been seen before. // Not sure what the best course of action is for it. diff --git a/docker-compose.yml b/docker-compose.yml index 69ca24b7..3bba8d9c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '3' services: frontend: - #build: ./frontend + build: ./frontend image: ghcr.io/frikky/shuffle-frontend:nightly container_name: shuffle-frontend hostname: shuffle-frontend @@ -16,7 +16,7 @@ services: depends_on: - backend backend: - #build: ./backend + build: ./backend image: ghcr.io/frikky/shuffle-backend:nightly container_name: shuffle-backend hostname: ${BACKEND_HOSTNAME} diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index eb04e147..a74153a9 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -105,7 +105,7 @@ const App = (message, props) => { :