From f866482f103e925a965da761302e2baab42abe7f Mon Sep 17 00:00:00 2001 From: Vladimir Kravchenko Date: Fri, 13 May 2022 17:50:24 +0300 Subject: [PATCH] Encrypt the password obtained from the flags --- cmd/root.go | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 1beace66..66944e75 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -48,7 +48,7 @@ func init() { persistent.StringP("database", "d", "./filebrowser.db", "database path") flags.Bool("noauth", false, "use the noauth auther when using quick setup") flags.String("username", "admin", "username for the first user when using quick config") - flags.String("password", "", "hashed password for the first user when using quick config (default \"admin\")") + flags.String("password", "admin", "hashed password for the first user when using quick config (default \"admin\")") addServerFlags(flags) } @@ -361,18 +361,9 @@ func quickSetup(flags *pflag.FlagSet, d pythonData) { username := getParam(flags, "username") password := getParam(flags, "password") - if password == "" { - password, err = users.HashPwd("admin") - checkErr(err) - } - - if username == "" || password == "" { - log.Fatal("username and password cannot be empty during quick setup") - } - user := &users.User{ Username: username, - Password: password, + Password: users.HashPwd(password), LockPassword: false, }