Improved api validation

This commit is contained in:
Graham Campbell
2015-11-21 21:18:40 +00:00
parent 8ecefc65fb
commit 60108fb7cc
8 changed files with 70 additions and 16 deletions

View File

@@ -16,9 +16,9 @@ use CachetHQ\Cachet\Commands\Component\RemoveComponentCommand;
use CachetHQ\Cachet\Commands\Component\UpdateComponentCommand;
use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\Tag;
use Exception;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Database\QueryException;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Http\Request;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
@@ -75,7 +75,7 @@ class ComponentController extends AbstractApiController
Binput::get('group_id'),
(bool) Binput::get('enabled', true)
));
} catch (Exception $e) {
} catch (QueryException $e) {
throw new BadRequestHttpException();
}
@@ -116,7 +116,7 @@ class ComponentController extends AbstractApiController
Binput::get('group_id'),
(bool) Binput::get('enabled', true)
));
} catch (Exception $e) {
} catch (QueryException $e) {
throw new BadRequestHttpException();
}

View File

@@ -15,8 +15,8 @@ use CachetHQ\Cachet\Commands\ComponentGroup\AddComponentGroupCommand;
use CachetHQ\Cachet\Commands\ComponentGroup\RemoveComponentGroupCommand;
use CachetHQ\Cachet\Commands\ComponentGroup\UpdateComponentGroupCommand;
use CachetHQ\Cachet\Models\ComponentGroup;
use Exception;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Database\QueryException;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Http\Request;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
@@ -63,7 +63,7 @@ class ComponentGroupController extends AbstractApiController
Binput::get('name'),
Binput::get('order', 0)
));
} catch (Exception $e) {
} catch (QueryException $e) {
throw new BadRequestHttpException();
}
@@ -85,7 +85,7 @@ class ComponentGroupController extends AbstractApiController
Binput::get('name'),
Binput::get('order', 0)
));
} catch (Exception $e) {
} catch (QueryException $e) {
throw new BadRequestHttpException();
}

View File

@@ -15,9 +15,9 @@ use CachetHQ\Cachet\Commands\Incident\RemoveIncidentCommand;
use CachetHQ\Cachet\Commands\Incident\ReportIncidentCommand;
use CachetHQ\Cachet\Commands\Incident\UpdateIncidentCommand;
use CachetHQ\Cachet\Models\Incident;
use Exception;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Database\QueryException;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Http\Request;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
@@ -77,7 +77,7 @@ class IncidentController extends AbstractApiController
Binput::get('template'),
Binput::get('vars')
));
} catch (Exception $e) {
} catch (QueryException $e) {
throw new BadRequestHttpException();
}
@@ -107,7 +107,7 @@ class IncidentController extends AbstractApiController
Binput::get('template'),
Binput::get('vars')
));
} catch (Exception $e) {
} catch (QueryException $e) {
throw new BadRequestHttpException();
}

View File

@@ -15,8 +15,8 @@ use CachetHQ\Cachet\Commands\Metric\AddMetricCommand;
use CachetHQ\Cachet\Commands\Metric\RemoveMetricCommand;
use CachetHQ\Cachet\Commands\Metric\UpdateMetricCommand;
use CachetHQ\Cachet\Models\Metric;
use Exception;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Database\QueryException;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Http\Request;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
@@ -80,7 +80,7 @@ class MetricController extends AbstractApiController
Binput::get('display_chart'),
Binput::get('places', 2)
));
} catch (Exception $e) {
} catch (QueryException $e) {
throw new BadRequestHttpException();
}
@@ -107,7 +107,7 @@ class MetricController extends AbstractApiController
Binput::get('display_chart'),
Binput::get('places', 2)
));
} catch (Exception $e) {
} catch (QueryException $e) {
throw new BadRequestHttpException();
}

View File

@@ -16,8 +16,8 @@ use CachetHQ\Cachet\Commands\Metric\RemoveMetricPointCommand;
use CachetHQ\Cachet\Commands\Metric\UpdateMetricPointCommand;
use CachetHQ\Cachet\Models\Metric;
use CachetHQ\Cachet\Models\MetricPoint;
use Exception;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Database\QueryException;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
@@ -53,7 +53,7 @@ class MetricPointController extends AbstractApiController
Binput::get('value'),
Binput::get('timestamp'))
);
} catch (Exception $e) {
} catch (QueryException $e) {
throw new BadRequestHttpException();
}

View File

@@ -14,8 +14,8 @@ namespace CachetHQ\Cachet\Http\Controllers\Api;
use CachetHQ\Cachet\Commands\Subscriber\SubscribeSubscriberCommand;
use CachetHQ\Cachet\Commands\Subscriber\UnsubscribeSubscriberCommand;
use CachetHQ\Cachet\Models\Subscriber;
use Exception;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Database\QueryException;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Http\Request;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
@@ -47,7 +47,7 @@ class SubscriberController extends AbstractApiController
{
try {
$subscriber = $this->dispatch(new SubscribeSubscriberCommand(Binput::get('email'), Binput::get('verify', false)));
} catch (Exception $e) {
} catch (QueryException $e) {
throw new BadRequestHttpException();
}