Пример #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) 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
}
Пример #3
0
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
}
Пример #4
0
// misc
func (node *Node) setId() {
	node.Id = uuid.New()
	return
}
Пример #5
0
func New() string {
	return gouuid.New()
}