mirror of https://github.com/portainer/portainer
29 lines
1012 B
Go
29 lines
1012 B
Go
package users
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/portainer/portainer"
|
|
httperror "github.com/portainer/portainer/http/error"
|
|
"github.com/portainer/portainer/http/request"
|
|
"github.com/portainer/portainer/http/response"
|
|
)
|
|
|
|
// GET request on /api/users/:id
|
|
func (handler *Handler) userInspect(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
|
|
userID, err := request.RetrieveNumericRouteVariableValue(r, "id")
|
|
if err != nil {
|
|
return &httperror.HandlerError{http.StatusBadRequest, "Invalid user identifier route variable", err}
|
|
}
|
|
|
|
user, err := handler.UserService.User(portainer.UserID(userID))
|
|
if err == portainer.ErrUserNotFound {
|
|
return &httperror.HandlerError{http.StatusNotFound, "Unable to find a user with the specified identifier inside the database", err}
|
|
} else if err != nil {
|
|
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to find a user with the specified identifier inside the database", err}
|
|
}
|
|
|
|
hideFields(user)
|
|
return response.JSON(w, user)
|
|
}
|