~emersion/soju

586c7ee3362c7c09cd92a697748139316ae0a85b — Kalyan Sriram a month ago cab0fc2
sojuctl: change-password: check if user exists

When changing the password, checks if the user exists *before* prompting
for a password change, instead of after.
1 files changed, 5 insertions(+), 4 deletions(-)

M cmd/sojuctl/main.go
M cmd/sojuctl/main.go => cmd/sojuctl/main.go +5 -4
@@ 84,6 84,11 @@ func main() {
			os.Exit(1)
		}

		user, err := db.GetUser(username)
		if err != nil {
			log.Fatalf("failed to get user: %v", err)
		}

		password, err := readPassword()
		if err != nil {
			log.Fatalf("failed to read password: %v", err)


@@ 94,10 99,6 @@ func main() {
			log.Fatalf("failed to hash password: %v", err)
		}

		user, err := db.GetUser(username)
		if err != nil {
			log.Fatalf("failed to get user: %v", err)
		}
		user.Password = string(hashed)
		if err := db.StoreUser(user); err != nil {
			log.Fatalf("failed to update password: %v", err)