Example #1
0
// value will be HTML escaped and concaternated
func (self *XMLWriter) Attrib(name string, value ...interface{}) *XMLWriter {
	errs.Assert(self.inOpenTag, "utils.XMLWriter.Attrib() must be called inside of open tag")

	fmt.Fprintf(self.writer, " %s='", name)
	for _, valuePart := range value {
		str := html.EscapeString(fmt.Sprint(valuePart))
		self.writer.Write([]byte(str))
	}
	self.writer.Write([]byte{'\''})

	return self
}
Example #2
0
func ConfirmEmail(confirmationCode string) (userDoc interface{}, email string, confirmed bool, err error) {
	query := Config.Collection.Filter("Email.ConfirmationCode", confirmationCode)
	userDoc, found, err := query.TryOne()
	if !found {
		return nil, "", false, err
	}
	user := From(userDoc)

	for i := range user.Email {
		if user.Email[i].ConfirmationCode.Get() == confirmationCode {
			user.Email[i].Confirmed.SetNowUTC()
			email = user.Email[i].Address.Get()
		}
	}
	errs.Assert(email != "", "ConfirmationCode has to be found")

	err = user.Save()
	if err != nil {
		return nil, "", false, err
	}

	return userDoc, email, true, nil
}
Example #3
0
func ConfirmEmail(confirmationCode string) (userID, email string, confirmed bool, err error) {
	query := Config.Collection.Filter("Email.ConfirmationCode", confirmationCode)
	var user User
	found, err := query.TryOneDocument(&user)
	if !found {
		return "", "", false, err
	}

	for i := range user.Email {
		if user.Email[i].ConfirmationCode.Get() == confirmationCode {
			user.Email[i].Confirmed.SetNowUTC()
			email = user.Email[i].Address.Get()
		}
	}
	errs.Assert(email != "", "ConfirmationCode has to be found")

	err = Config.Collection.UpdateSubDocumentWithID(user.ID, "", &user)
	if err != nil {
		return "", "", false, err
	}

	return user.ID.Hex(), email, true, nil
}