Example #1
0
File: main.go Project: zbzzbd/beego
func createUser(name, email, password string, companyId int, roles []user.RoleType) (err error) {
	c := user.NewCreation(name, email, password, companyId, roles)
	log.Println(utils.Sdump(c))
	if err = c.Do(); err != nil {
		return
	}
	return
}
Example #2
0
File: user.go Project: zbzzbd/beego
func (c *UserController) PostCreate() {
	roles := []user.RoleType{user.RoleType(c.GetString("role"))}
	companyId, _ := c.GetInt("company")
	err := user.NewCreation(c.GetString("name"), c.GetString("email"), "123456", companyId, roles).Do()

	if err != nil {
		c.SetJsonResponse("error", err.Error())
	}

	c.GetJsonResponse().ServeJson()
}