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

45 lines
894 B
Go
Raw Normal View History

2018-09-20 19:42:01 +02:00
package v1
import (
2018-10-31 13:42:38 +01:00
"code.vikunja.io/api/pkg/models"
"code.vikunja.io/api/pkg/routes/crud"
2018-09-20 19:42:01 +02:00
"github.com/labstack/echo"
"net/http"
)
// UserList gets all information about a user
func UserList(c echo.Context) error {
// swagger:operation GET /users user list
// ---
// summary: Lists all users
// consumes:
// - application/json
// produces:
// - application/json
// parameters:
// - name: s
// description: A searchterm to search for a user by its username
// in: query
// responses:
// "200":
// "$ref": "#/responses/User"
// "400":
// "$ref": "#/responses/Message"
// "500":
// "$ref": "#/responses/Message"
s := c.QueryParam("s")
users, err := models.ListUsers(s)
if err != nil {
2018-10-06 15:04:14 +02:00
return crud.HandleHTTPError(err)
2018-09-20 19:42:01 +02:00
}
// Obfuscate the mailadresses
for in := range users {
users[in].Email = ""
}
return c.JSON(http.StatusOK, users)
}