Example #1
0
func (rcv *controller) put() []error {
	var errs []error

	// Map html input value to fields
	if fieldsErrs := binding.Bind(rcv.Request, rcv.formUser); fieldsErrs != nil {

		for _, e := range fieldsErrs {
			errs = append(errs, errors.New(e.Message))
		}
		return errs
	}

	// Validate captcha
	if err := captcha.Validate(rcv.Request, rcv.formUser.Certification, rcv.formUser.Human); err != nil {
		return []error{err}
	}

	if err := rcv.updateEmail(); err != nil {
		errs = append(errs, err)
	}

	if err := rcv.updateName(); err != nil {
		errs = append(errs, err)
	}

	return errs
}
Example #2
0
func (rcv *controller) post() []error {

	var errs []error

	// Map html input value to fields
	if formErrs := binding.Bind(rcv.Request, rcv.formUser); formErrs != nil {

		for _, e := range formErrs {
			errs = append(errs, errors.New(e.Message))
		}
		return errs
	}

	// Validate captcha
	if err := captcha.Validate(rcv.Request, rcv.formUser.Certification, rcv.formUser.Human); err != nil {
		return []error{errors.New(rcv.Translate("text09"))}
	}

	if errs := maccount.Create(rcv.formUser.Name, rcv.formUser.Email, rcv.formUser.Password, rcv.Local, rcv.formUser.TermOf); errs != nil {
		return errs
	}

	if err := rcv.sendActivationLink(rcv.formUser.Email); err != nil {
		return []error{err}
	}

	return nil

}