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 New() string { return gouuid.New() }