diff --git a/cmd/user.go b/cmd/user.go index f2a5fe754..1e1492ddb 100644 --- a/cmd/user.go +++ b/cmd/user.go @@ -142,6 +142,7 @@ func promptPassword() string { log.Fatal("Error getting password confirmation", err) } + // clear the line. fmt.Println() pass := string(password) @@ -155,7 +156,7 @@ func promptPassword() string { return pass } - fmt.Print("Username and password do not match") + fmt.Println("Password and password confirmation do not match") } } @@ -368,7 +369,18 @@ func runUserList() { if outputFormat == "csv" { w := csv.NewWriter(os.Stdout) - _ = w.Write([]string{"user id", "username", "user's name", "user email", "admin", "created at", "updated at", "last access", "last login", "last login", "libraries"}) + _ = w.Write([]string{ + "user id", + "username", + "user's name", + "user email", + "admin", + "created at", + "updated at", + "last access", + "last login", + "libraries", + }) for _, user := range userList { paths := make([]string, len(user.Libraries)) @@ -376,6 +388,20 @@ func runUserList() { paths[idx] = fmt.Sprintf("%d:%s", library.ID, library.Path) } + var lastAccess, lastLogin string + + if user.LastAccessAt != nil { + lastAccess = user.LastAccessAt.Format(time.RFC3339Nano) + } else { + lastAccess = "never" + } + + if user.LastLoginAt != nil { + lastLogin = user.LastLoginAt.Format(time.RFC3339Nano) + } else { + lastLogin = "never" + } + _ = w.Write([]string{ user.ID, user.UserName, @@ -384,8 +410,8 @@ func runUserList() { strconv.FormatBool(user.IsAdmin), user.CreatedAt.Format(time.RFC3339Nano), user.UpdatedAt.Format(time.RFC3339Nano), - user.LastAccessAt.Format(time.RFC3339Nano), - user.LastLoginAt.Format(time.RFC3339Nano), + lastAccess, + lastLogin, fmt.Sprintf("'%s'", strings.Join(paths, ",")), }) } diff --git a/go.mod b/go.mod index f3934575c..2abf5f3a1 100644 --- a/go.mod +++ b/go.mod @@ -66,6 +66,7 @@ require ( golang.org/x/net v0.47.0 golang.org/x/sync v0.18.0 golang.org/x/sys v0.38.0 + golang.org/x/term v0.37.0 golang.org/x/text v0.31.0 golang.org/x/time v0.14.0 google.golang.org/protobuf v1.36.10 @@ -131,7 +132,6 @@ require ( golang.org/x/crypto v0.45.0 // indirect golang.org/x/mod v0.30.0 // indirect golang.org/x/telemetry v0.0.0-20251111182119-bc8e575c7b54 // indirect - golang.org/x/term v0.37.0 // indirect golang.org/x/tools v0.39.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect