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 }
func (u *User) SetMongoInfo() (err error) { if uu, admin, err := dbGetInfo(u.Username); err == nil { u.Uuid = uu u.Admin = admin return nil } else { u.Uuid = uuid.New() if err := u.Save(); err != nil { return err } } return }
func (u *User) SetMongoInfo() (err error) { if uu, admin, err := dbGetInfo(u.Username); err == nil { u.Uuid = uu u.Admin = admin return nil } else { // this is a new user u.Uuid = uuid.New() // check if user is on admin list, if so set as true for k, _ := range conf.Admin_Users { if k == u.Username { u.Admin = true break } } if err := u.Save(); err != nil { return err } } return }
// misc func (node *Node) setId() { node.Id = uuid.New() return }
func New() string { return gouuid.New() }