vikunja/pkg/routes/api/v1/user_list.go

36 lines
928 B
Go
Raw Normal View History

2018-09-20 17:42:01 +00:00
package v1
import (
2018-10-31 12:42:38 +00:00
"code.vikunja.io/api/pkg/models"
"code.vikunja.io/api/pkg/routes/crud"
2018-09-20 17:42:01 +00:00
"github.com/labstack/echo"
"net/http"
)
// UserList gets all information about a user
// @Summary Get users
// @Description Lists all users (without emailadresses). Also possible to search for a specific user.
// @tags user
// @Accept json
// @Produce json
// @Param s query string false "Search for a user by its name."
// @Security ApiKeyAuth
// @Success 200 {array} models.User "All (found) users."
// @Failure 400 {object} models.HTTPError "Something's invalid."
// @Failure 500 {object} models.Message "Internal server error."
// @Router /users [get]
2018-09-20 17:42:01 +00:00
func UserList(c echo.Context) error {
s := c.QueryParam("s")
users, err := models.ListUsers(s)
if err != nil {
2018-10-06 13:04:14 +00:00
return crud.HandleHTTPError(err)
2018-09-20 17:42:01 +00:00
}
// Obfuscate the mailadresses
for in := range users {
users[in].Email = ""
}
return c.JSON(http.StatusOK, users)
}