Skip to content

Commit

Permalink
Merge pull request #75 from GOCDB/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
GRyall authored Feb 2, 2017
2 parents 81b6d76 + a0be8c7 commit 02219b0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/Gocdb_Services/ServiceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -1784,6 +1784,9 @@ public function addEndpoint($values, \User $user = null) {
$serviceID = $values ['SERVICEENDPOINT'] ['SERVICE'];
$service = $this->getService ( $serviceID );

// check user has permission to edit endpoint's service
$this->validateAddEditDeleteActions ( $user, $service );

$name = $values ['SERVICEENDPOINT'] ['NAME'];
$url = $values ['SERVICEENDPOINT'] ['URL'];
$description = $values ['SERVICEENDPOINT'] ['DESCRIPTION'];
Expand Down Expand Up @@ -1849,6 +1852,13 @@ public function editEndpoint(\Service $service, \User $user, \EndpointLocation $
$this->checkPortalIsNotReadOnlyOrUserIsAdmin ( $user );
$this->validate ( $newValues ['SERVICEENDPOINT'], 'endpoint' );

//We shouldn't rely on the service being given to the function - this allows bugs to be introduced that feed the wrong service
//TODO: remove the $service from the endpoint parameters
$service = $endpoint->getService ();

// check user has permission to edit endpoint's service
$this->validateAddEditDeleteActions ( $user, $service );

$name = $newValues ['SERVICEENDPOINT'] ['NAME'];
$url = $newValues ['SERVICEENDPOINT'] ['URL'];
$description = $newValues ['SERVICEENDPOINT'] ['DESCRIPTION'];
Expand Down Expand Up @@ -1907,9 +1917,12 @@ public function editEndpoint(\Service $service, \User $user, \EndpointLocation $
*/
public function deleteEndpoint(\EndpointLocation $endpoint, \User $user) {
require_once __DIR__ . '/../DAOs/ServiceDAO.php';

// Check the portal is not in read only mode, throws exception if it is
$this->checkPortalIsNotReadOnlyOrUserIsAdmin ( $user );

$service = $endpoint->getService ();

// check user has permission to edit endpoint's service
$this->validateAddEditDeleteActions ( $user, $service );

Expand Down

0 comments on commit 02219b0

Please sign in to comment.