diff --git a/api/dataservices/endpoint/tx.go b/api/dataservices/endpoint/tx.go index 4b662ec48..457ebdf89 100644 --- a/api/dataservices/endpoint/tx.go +++ b/api/dataservices/endpoint/tx.go @@ -27,6 +27,8 @@ func (service ServiceTx) Endpoint(ID portainer.EndpointID) (*portainer.Endpoint, return nil, err } + endpoint.LastCheckInDate, _ = service.service.Heartbeat(ID) + return &endpoint, nil } diff --git a/api/http/handler/endpointedge/endpoint_edgestatus_inspect.go b/api/http/handler/endpointedge/endpoint_edgestatus_inspect.go index b7b156aec..04fc88030 100644 --- a/api/http/handler/endpointedge/endpoint_edgestatus_inspect.go +++ b/api/http/handler/endpointedge/endpoint_edgestatus_inspect.go @@ -98,6 +98,13 @@ func (handler *Handler) endpointEdgeStatusInspect(w http.ResponseWriter, r *http return httperror.Forbidden("Permission denied to access environment", err) } + handler.DataStore.Endpoint().UpdateHeartbeat(endpoint.ID) + + err = handler.requestBouncer.TrustedEdgeEnvironmentAccess(handler.DataStore, endpoint) + if err != nil { + return httperror.Forbidden("Permission denied to access environment", err) + } + var statusResponse *endpointEdgeStatusInspectResponse if featureflags.IsEnabled(portainer.FeatureNoTx) { statusResponse, err = handler.inspectStatus(handler.DataStore, r, portainer.EndpointID(endpointID)) @@ -126,11 +133,6 @@ func (handler *Handler) inspectStatus(tx dataservices.DataStoreTx, r *http.Reque return nil, err } - err = handler.requestBouncer.TrustedEdgeEnvironmentAccess(tx, endpoint) - if err != nil { - return nil, httperror.Forbidden("Permission denied to access environment", err) - } - if endpoint.EdgeID == "" { edgeIdentifier := r.Header.Get(portainer.PortainerAgentEdgeIDHeader) endpoint.EdgeID = edgeIdentifier