Changes
4 changed files (+29/-14)
-
-
@@ -35,12 +35,11 @@ Logger: logger,}, nil } // TODO: Allow sepcifying admin creation password func (core *Core) Init() error { return core.generateAdminCreationPassword() func (core *Core) Init(adminCreationPassword string) error { return core.generateAdminCreationPassword(adminCreationPassword) } func (core *Core) generateAdminCreationPassword() error { func (core *Core) generateAdminCreationPassword(givenPassword string) error { tx, err := core.DB.Begin() if err != nil { return err
-
@@ -69,9 +68,14 @@ if workspace.Projection.NumberOfAdmins != nil && *workspace.Projection.NumberOfAdmins > 0 {return nil } core.Logger.Debug("Generating admin creation password...") core.Logger.Debug("Configuring admin creation password...") password := rand.Text() password := givenPassword isPasswordAutogenerated := false if password == "" { password = rand.Text() isPasswordAutogenerated = true } err = event.AppendEvents(tx, []*eventsV1.Event{ workspaceEvent.GenerateAdminCreationPassword(password),
-
@@ -84,11 +88,15 @@ if err := tx.Commit(); err != nil {return err } core.Logger.Info( "Generated admin creation password. Use this for initial admin user creation.", "admin_creation_password", password, ) if isPasswordAutogenerated { core.Logger.Info( "Generated admin creation password. Use this for initial admin user creation.", "admin_creation_password", password, ) } else { core.Logger.Info("Configured admin creation password. Use that for initial admin user creation.") } return nil }
-
-
-
@@ -8,6 +8,7 @@import ( "database/sql" _ "embed" "flag" "log/slog" "net/http" "os"
-
@@ -18,10 +19,16 @@ "pocka.jp/x/yamori/backend/core""pocka.jp/x/yamori/backend/services" _ "modernc.org/sqlite" ) var adminCreationPassword = flag.String( "admin-creation-password", "", "Password for creating a user when there is no admin user in workspace", ) // TODO: エラーコードを定義する func main() { flag.Parse() // TODO: CLI 引数で JSONL ロガーと charmbracelet/log を選べるようにする logger := slog.New(slog.NewJSONHandler(os.Stdout, nil)) db, err := sql.Open("sqlite", ":memory:")
-
@@ -36,7 +43,7 @@ logger.Error("Failed to create core instance", "error", err)os.Exit(3) } if err := core.Init(); err != nil { if err := core.Init(*adminCreationPassword); err != nil { logger.Error("Failed to prepare application core", "error", err) os.Exit(4) }
-
-
-
@@ -38,7 +38,7 @@ if err != nil {t.Fatal(err) } if err := core.Init(); err != nil { if err := core.Init("initial_admin_password"); err != nil { t.Fatal(err) }
-
-
-
@@ -34,7 +34,7 @@ logger.Error("Failed to create core instance", "error", err)os.Exit(3) } if err := core.Init(); err != nil { if err := core.Init(""); err != nil { logger.Error("Failed to prepare application core", "error", err) os.Exit(4) }
-