//ConfirmValidation checks if the supplied code matches the username and key
489393
func (service *IYOPhonenumberValidationService) ConfirmValidation(request *http.Request, key, code string) (err error) {
	info, err := service.getPhonenumberValidationInformation(request, key)
	if err != nil {
		return
	}
	if info == nil {
		err = ErrInvalidOrExpiredKey
		return
	}
	if info.SMSCode != code {
		err = ErrInvalidCode
		return
	}
	valMngr := validation.NewManager(request)
	p := valMngr.NewValidatedPhonenumber(info.Username, info.Phonenumber)
	err = valMngr.SaveValidatedPhonenumber(p)
	if err != nil {
		return
	}
	err = valMngr.UpdatePhonenumberValidationInformation(key, true)
	if err != nil {
		return
	}
	return
}
798667
func (v *EmailIsPresent) IsValid(errors *validate.Errors) {
	if !rxEmail.Match([]byte(v.Field)) {
		if v.Message == "" {
			v.Message = fmt.Sprintf("%s does not match the email format.", v.Name)
		}
		errors.Add(GenerateKey(v.Name), v.Message)
	}
}
1085533
func (s SecretForDockerRegistryGeneratorV1) validate() error {
	if len(s.Name) == 0 {
		return fmt.Errorf("name must be specified")
	}

	if len(s.FileSources) == 0 {
		if len(s.Username) == 0 {
			return fmt.Errorf("username must be specified")
		}
		if len(s.Password) == 0 {
			return fmt.Errorf("password must be specified")
		}
		if len(s.Server) == 0 {
			return fmt.Errorf("server must be specified")
		}
	}
	return nil
}
39989
func (m gwMetaV1) IsValid() bool {
	return ((m.Version == gwMetaVersion || m.Version == gwMetaVersion100) &&
		m.Format == gwMetaFormat)
}
1072873
func (service *IYOEmailAddressValidationService) RequestValidation(request *http.Request, username string, email string, confirmationurl string, langKey string) (key string, err error) {
	valMngr := validation.NewManager(request)
	info, err := valMngr.NewEmailAddressValidationInformation(username, email)
	if err != nil {
		log.Error(err)
		return
	}
	err = valMngr.SaveEmailAddressValidationInformation(info)
	if err != nil {
		log.Error(err)
		return
	}

	translationValues := tools.TranslationValues{
		"emailvalidation_title":      nil,
		"emailvalidation_text":       struct{ Email string }{Email: email},
		"emailvalidation_buttontext": nil,
		"emailvalidation_reason":     nil,
		"emailvalidation_subject":    nil,
		"emailvalidation_urlcaption": nil,
	}

	translations, err := tools.ParseTranslations(langKey, translationValues)
	if err != nil {
		log.Error("Failed to parse translations: ", err)
		return
	}

	validationurl := fmt.Sprintf("%s?c=%s&k=%s&l=%s", confirmationurl, url.QueryEscape(info.Secret), url.QueryEscape(info.Key), langKey)
	templateParameters := EmailWithButtonTemplateParams{
		UrlCaption: translations["emailvalidation_urlcaption"],
		Url:        validationurl,
		Username:   username,
		Title:      translations["emailvalidation_title"],
		Text:       translations["emailvalidation_text"],
		ButtonText: translations["emailvalidation_buttontext"],
		Reason:     translations["emailvalidation_reason"],
		LogoUrl:    fmt.Sprintf("https://%s/assets/img/its-you-online.png", request.Host),
	}
	message, err := tools.RenderTemplate(emailWithButtonTemplateName, templateParameters)
	if err != nil {
		return
	}

	go service.EmailService.Send([]string{email}, translations["emailvalidation_subject"], message)
	key = info.Key
	return
}
409838
func (s Signature) IsValid(key string, r *http.Request) bool {
	if !s.Headers.hasDate() {
		return false
	}

	sig, err := s.calculateSignature(key, r)
	if err != nil {
		return false
	}

	return subtle.ConstantTimeCompare([]byte(s.Signature), []byte(sig)) == 1
}
1344244
func (cred Credentials) IsValid() bool {
	// Verify credentials if its enabled or not set.
	if cred.Status == "enabled" || cred.Status == "" {
		return IsAccessKeyValid(cred.AccessKey) && IsSecretKeyValid(cred.SecretKey) && !cred.IsExpired()
	}
	return false
}
89861
func (key CredentialKey) Validate(_ interface{}) error {
	if credentialKeyRegex.Match([]byte(key)) {
		return nil
	}

	return errInvalidCredentialKey
}
71302
func ValidKeyTokens(name string, tags Tags) bool {
	if !ValidKeyToken(name) {
		return false
	}
	for _, tag := range tags {
		if !ValidKeyToken(string(tag.Key)) || !ValidKeyToken(string(tag.Value)) {
			return false
		}
	}
	return true
}
741368
func (v *UUIDIsPresent) IsValid(errors *validate.Errors) {
	s := v.Field.String()
	if strings.TrimSpace(s) != "" && v.Field != uuid.Nil {
		return
	}

	if len(v.Message) > 0 {
		errors.Add(GenerateKey(v.Name), v.Message)
		return
	}

	errors.Add(GenerateKey(v.Name), fmt.Sprintf("%s can not be blank.", v.Name))
}
24300
func (token *Token) Validate(securityCode string) (valid bool) {

	totp := otp.TOTP{
		Secret:         token.Secret,
		IsBase32Secret: true,
	}
	valid = totp.Now().Verify(securityCode)
	return

}
1359955
func (u *modelUserEntity) PasswordValid(pass string) bool {
	if u.user == nil {
		return false
	}
	return u.user.PasswordValid(pass)
}
553707
func (pwm *Manager) Validate(username, securityCode string) (bool, error) {

	var storedSecret userSecret
	if err := pwm.collection.Find(bson.M{"username": username}).One(&storedSecret); err != nil {
		if err == mgo.ErrNotFound {
			log.Debug("No totpsecret found for this user")
			return false, nil
		}
		log.Debug(err)
		return false, err
	}
	token := TokenFromSecret(storedSecret.Secret)
	match := token.Validate(securityCode)
	return match, nil
}
1146580
func PasswordValid(hash, password []byte) bool {
	p := matchProvider(hash)
	if p == nil {
		return false
	}
	return p.Valid(hash, password)
}
1292723
func (state *UserState) RemoveUnconfirmed(username string) {
	state.unconfirmed.Del(username)
	state.users.DelKey(username, "confirmationCode")
}
1157964
func (state *UserState) AddUnconfirmed(username, confirmationCode string) {
	state.unconfirmed.Add(username)
	state.users.Set(username, "confirmationCode", confirmationCode)
}
142646
func (m *Meta) confirm(opts *terraform.InputOpts) (bool, error) {
	if !m.Input() {
		return false, errors.New("input is disabled")
	}

	for i := 0; i < 2; i++ {
		v, err := m.UIInput().Input(context.Background(), opts)
		if err != nil {
			return false, fmt.Errorf(
				"Error asking for confirmation: %s", err)
		}

		switch strings.ToLower(v) {
		case "no":
			return false, nil
		case "yes":
			return true, nil
		}
	}
	return false, nil
}