// CheckPasswd checks the provided password to see if it matches the stored // password hash. func (u *User) CheckPasswd(password string) util.Gerror { h, perr := chefcrypto.HashPasswd(password, u.salt) if perr != nil { err := util.Errorf(perr.Error()) return err } if u.passwd != h { err := util.Errorf("password did not match") return err } return nil }
// SetPasswd validates and sets the user's password. Will not set a password for // a client. func (u *User) SetPasswd(password string) util.Gerror { if len(password) < 6 { err := util.Errorf("Password must have at least 6 characters") return err } /* If those validations pass, set the password */ var perr error u.passwd, perr = chefcrypto.HashPasswd(password, u.salt) if perr != nil { err := util.Errorf(perr.Error()) return err } return nil }