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) 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
}
Example #3
0
File: user.go Project: MG-RAST/AWE
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
}
Example #4
0
// misc
func (node *Node) setId() {
	node.Id = uuid.New()
	return
}
Example #5
0
File: uuid.go Project: MG-RAST/AWE
func New() string {
	return gouuid.New()
}