feat: only hash if it's default pw

License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
This commit is contained in:
Henrique Dias 2019-01-06 17:55:47 +00:00
parent a2742dff16
commit 550269d2ed
1 changed files with 7 additions and 4 deletions

View File

@ -43,7 +43,7 @@ func init() {
vaddP(f, "scope", "s", ".", "scope to prepend to a user's scope when it is relative") vaddP(f, "scope", "s", ".", "scope to prepend to a user's scope when it is relative")
vaddP(f, "baseurl", "b", "", "base url") vaddP(f, "baseurl", "b", "", "base url")
vadd(f, "username", "admin", "username for the first user when using quick config") vadd(f, "username", "admin", "username for the first user when using quick config")
vadd(f, "password", "admin", "password for the first user when using quick config") vadd(f, "password", "", "hashed password for the first user when using quick config (default \"admin\")")
if err := v.BindPFlags(f); err != nil { if err := v.BindPFlags(f); err != nil {
panic(err) panic(err)
@ -197,13 +197,16 @@ func quickSetup(cmd *cobra.Command) {
username := v.GetString("username") username := v.GetString("username")
password := v.GetString("password") password := v.GetString("password")
if password == "" {
password, err = users.HashPwd("admin")
checkErr(err)
}
if username == "" || password == "" { if username == "" || password == "" {
checkErr(errors.New("username and password cannot be empty during quick setup")) checkErr(errors.New("username and password cannot be empty during quick setup"))
} }
password, err = users.HashPwd(password)
checkErr(err)
user := &users.User{ user := &users.User{
Username: username, Username: username,
Password: password, Password: password,