From 4b99a6ce140ba2d2a4dbea60e8fc46abd77dbb41 Mon Sep 17 00:00:00 2001 From: Pankaj Sha Date: Thu, 23 Jan 2025 01:19:43 +0530 Subject: [PATCH 1/2] fix: set password against user when passed as flag --- server/main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/main.go b/server/main.go index edac4ada7..13f06ba09 100644 --- a/server/main.go +++ b/server/main.go @@ -72,7 +72,11 @@ func Start() { // and new users in a much better way. Doing this using // and empty password check is not a good solution. if config.Config.Password != "" { - _, _ = auth.UserStore.Add(config.Config.Username) + user, _ := auth.UserStore.Add(config.Config.Username) + if err:= user.SetPassword(config.Config.Password); err != nil { + slog.Error("Could not set password", slog.String("password", config.Config.Password), slog.Any("error", err)) + return + } } ctx, cancel := context.WithCancel(context.Background()) From 4771c2c99e6a78dadf66f3cbd5fd4d68952ff4a9 Mon Sep 17 00:00:00 2001 From: Pankaj Sha Date: Thu, 23 Jan 2025 12:44:41 +0530 Subject: [PATCH 2/2] chore: remove error check which is unlikely to happen --- server/main.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/server/main.go b/server/main.go index 13f06ba09..0c356d6e8 100644 --- a/server/main.go +++ b/server/main.go @@ -73,10 +73,7 @@ func Start() { // and empty password check is not a good solution. if config.Config.Password != "" { user, _ := auth.UserStore.Add(config.Config.Username) - if err:= user.SetPassword(config.Config.Password); err != nil { - slog.Error("Could not set password", slog.String("password", config.Config.Password), slog.Any("error", err)) - return - } + _ = user.SetPassword(config.Config.Password) } ctx, cancel := context.WithCancel(context.Background())