From da9d3f4c82c7e3b50852edf720cd355f15eb26aa Mon Sep 17 00:00:00 2001 From: yashsinghcodes Date: Thu, 28 Nov 2024 02:08:44 +0530 Subject: [PATCH 1/2] a quick fix for #1510 where SHUFFLE_DEFAULT_USERNAME doesn't set up account --- backend/go-app/main.go | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/backend/go-app/main.go b/backend/go-app/main.go index 1e8dfddf..5771d76c 100755 --- a/backend/go-app/main.go +++ b/backend/go-app/main.go @@ -4009,11 +4009,23 @@ func runInitEs(ctx context.Context) { log.Printf("[DEBUG] Creating org for default user %s", username) orgId := uuid.NewV4().String() orgSetupName := "default" + tmpOrg := shuffle.OrgMini{ + Name: orgSetupName, + Id: orgId, + } + err = createNewUser(username, password, "admin", apikey, tmpOrg) + if err != nil { + log.Printf("[ERROR] Failed to create default user %s: %s", username, err) + } else { + log.Printf("[INFO] Successfully created user %s", username) + } + + user, err := shuffle.GetUser(ctx, username) newOrg := shuffle.Org{ Name: orgSetupName, Id: orgId, Org: orgSetupName, - Users: []shuffle.User{}, + Users: []shuffle.User{*user}, Roles: []string{"admin", "user"}, CloudSync: false, } @@ -4021,7 +4033,7 @@ func runInitEs(ctx context.Context) { err = shuffle.SetOrg(ctx, newOrg, newOrg.Id) setUsers := false if err != nil { - log.Printf("[WARNING] Failed setting organization when creating original user: %s", err) + log.Printf("[ERROR] Failed setting organization when creating original user: %s", err) } else { log.Printf("[DEBUG] Successfully created the default org with id %s!", orgId) setUsers = true @@ -4041,17 +4053,6 @@ func runInitEs(ctx context.Context) { } if setUsers { - tmpOrg := shuffle.OrgMini{ - Name: orgSetupName, - Id: orgId, - } - - err = createNewUser(username, password, "admin", apikey, tmpOrg) - if err != nil { - log.Printf("[INFO] Failed to create default user %s: %s", username, err) - } else { - log.Printf("[INFO] Successfully created user %s", username) - } } } } else { @@ -5026,7 +5027,7 @@ func initHandlers() { go runInitEs(ctx) } else { //go shuffle.runInit(ctx) - log.Printf("[ERROR] Opensearch is the only viable option. Please set SHUFFLE_ELASTIC=true") + log.Printf("[ERROR] Opensearch is the only viable option. Please set SHUFFLE_ELASTIC=true") os.Exit(1) } From ca4db692e61ae97c5992b15cb179916bb81cc4a7 Mon Sep 17 00:00:00 2001 From: yashsinghcodes Date: Thu, 28 Nov 2024 02:11:59 +0530 Subject: [PATCH 2/2] remove unused variables --- backend/go-app/main.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/backend/go-app/main.go b/backend/go-app/main.go index 5771d76c..53d0f498 100755 --- a/backend/go-app/main.go +++ b/backend/go-app/main.go @@ -4031,12 +4031,10 @@ func runInitEs(ctx context.Context) { } err = shuffle.SetOrg(ctx, newOrg, newOrg.Id) - setUsers := false if err != nil { log.Printf("[ERROR] Failed setting organization when creating original user: %s", err) } else { log.Printf("[DEBUG] Successfully created the default org with id %s!", orgId) - setUsers = true item := shuffle.Environment{ Name: defaultEnv, @@ -4051,9 +4049,6 @@ func runInitEs(ctx context.Context) { log.Printf("[WARNING] Failed setting up new environment") } } - - if setUsers { - } } } else { for _, user := range users {