Example #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
}
Example #2
0
func (u *User) SetUuid() (err error) {
	if d, err := DBConnect(); err == nil {
		defer d.Close()
		if uu, err := d.GetUuid(u.Username); err == nil {
			u.Uuid = uu
			return nil
		} else {
			u.Uuid = uuid.New()
			if err := d.Insert(u); err != nil {
				return err
			}
		}
	}
	return
}
Example #3
0
func (node *Node) setId() {
	node.Id = uuid.New()
	return
}