Пример #1
0
func New(username string, password string, isAdmin bool) (u *User, err error) {
	u = &User{Uuid: uuid.New(), Username: username, Password: password, Admin: isAdmin}
	if err = u.Save(); err != nil {
		u = nil
	}
	return
}
Пример #2
0
func (u *User) SetUuid() (err error) {
	if d, err := DBConnect(); err == nil {
		defer d.Close()
		if uu, err := d.GetUuid(u.Email); err == nil {
			u.Uuid = uu
			return nil
		} else {
			u.Uuid = uuid.New()
			if err := d.Insert(u); err != nil {
				return err
			}
		}
	}
	return
}
Пример #3
0
func (node *Node) setId() {
	node.Id = uuid.New()
	return
}