Corrects validation logic for static password check

This commit is contained in:
krishnadurai 2019-12-13 16:52:10 -08:00
parent 91cbd466a5
commit af9c2880a6

View file

@ -99,12 +99,11 @@ func (p *password) UnmarshalJSON(b []byte) error {
Username: data.Username, Username: data.Username,
UserID: data.UserID, UserID: data.UserID,
}) })
if len(data.Hash) == 0 { if len(data.Hash) == 0 && len(data.HashFromEnv) > 0 {
if len(data.HashFromEnv) > 0 {
data.Hash = os.Getenv(data.HashFromEnv) data.Hash = os.Getenv(data.HashFromEnv)
} else {
return fmt.Errorf("no password hash provided")
} }
if len(data.Hash) == 0 {
return fmt.Errorf("no password hash provided")
} }
// If this value is a valid bcrypt, use it. // If this value is a valid bcrypt, use it.