Example #1
0
// usersGetAll return all users
func usersGetAll(w http.ResponseWriter, r *http.Request) {
	if !authorized(w, r) {
		return
	}
	users, err := api.UserGetAll()
	if err != nil {
		httpWriteErrorJson(w, 500, "unable to get users", err.Error())
		return
	}
	js, err := json.Marshal(users)
	if err != nil {
		httpWriteErrorJson(w, 500, "JSON encondig failed", err.Error())
		return
	}
	httpWriteJson(w, js)
}
Example #2
0
File: user.go Project: ro78/tmail
			Action: func(c *cgCli.Context) {
				var err error
				if len(c.Args()) != 1 {
					cliDieBadArgs(c)
				}
				err = api.UserDel(c.Args()[0])
				cliHandleErr(err)
				cliDieOk()
			},
		},
		{
			Name:        "list",
			Usage:       "Return a list of users",
			Description: "",
			Action: func(c *cgCli.Context) {
				users, err := api.UserGetAll()
				cliHandleErr(err)
				if len(users) == 0 {
					println("There is no users yet.")
					return
				}
				for _, user := range users {
					line := user.Login + " - authrelay: "
					if user.AuthRelay {
						line += "yes"
					} else {
						line += "no"
					}
					line += " - have mailbox: "
					if user.HaveMailbox {
						line += "yes - home: " + user.Home