func (this *User) ValidatePassword(v *r.Validation, password string) { bin := []byte(_APPSECRET + password + this.Username) hbin, _ := base64.StdEncoding.DecodeString(this.Password) err := bcrypt.CompareHashAndPassword(hbin, bin) if err != nil { v.Error("密码不匹配") } }
func (user *User) Validate(v *revel.Validation) { v.Required(user.Password) //v.MinSize(user.Password, 6) v.Required(user.Email) v.Email(user.Email) if user.Email == "*****@*****.**" && user.Password == "test" { user.Id = "6964943e-535a-4736-85ad-4baaa9656709" } else { v.Error("Sorry! invalid account ...") } }