Commit e7af8026 authored by Jacob Priddy's avatar Jacob Priddy 👌
Browse files

Protect door routes

parent b3fa4008
Pipeline #5509 passed with stages
in 2 minutes and 6 seconds
......@@ -57,10 +57,14 @@ class DoorsController extends ApiController
* @param \Source\UseCases\Doors\CreateDoor\CreateDoorUseCase $createDoor
* @return \Illuminate\Http\JsonResponse
* @throws \Illuminate\Validation\ValidationException
* @throws \Source\Exceptions\AuthorizationException
* @throws \Source\Exceptions\EntityExistsException
* @throws \Source\Exceptions\EntityNotFoundException
*/
public function store(CreateDoorUseCase $createDoor): JsonResponse
{
$this->authorizer->protectAll([Permissions::MANAGE_DOORS]);
$this->validate($this->request, [
'location' => 'required|string|max:255',
'name' => 'required|string|max:255',
......@@ -81,9 +85,12 @@ class DoorsController extends ApiController
* @return \Illuminate\Http\JsonResponse
* @throws \Illuminate\Validation\ValidationException
* @throws \Source\Exceptions\EntityNotFoundException
* @throws \Source\Exceptions\AuthorizationException
*/
public function update(UpdateDoorUseCase $updateDoor, string $doorId): JsonResponse
{
$this->authorizer->protectAll([Permissions::MANAGE_DOORS]);
$this->validate($this->request, [
'location' => 'string|max:255',
'name' => 'string|max:255',
......@@ -102,9 +109,12 @@ class DoorsController extends ApiController
* @param string $doorId
* @return \Illuminate\Http\JsonResponse
* @throws \Source\Exceptions\EntityNotFoundException
* @throws \Source\Exceptions\AuthorizationException
*/
public function regenerateToken(GenerateDoorTokenUseCase $tokenGenerator, string $doorId): JsonResponse
{
$this->authorizer->protectAll([Permissions::MANAGE_DOORS]);
$presenter = new CreateDoorAPIPresenter();
$tokenGenerator->generate($doorId, config('app.key'), $presenter);
......@@ -117,9 +127,12 @@ class DoorsController extends ApiController
* @param string $doorId
* @return \Illuminate\Http\JsonResponse
* @throws \Source\Exceptions\EntityNotFoundException
* @throws \Source\Exceptions\AuthorizationException
*/
public function delete(DeleteDoorUseCase $doorDelyeeter, string $doorId): JsonResponse
{
$this->authorizer->protectAll([Permissions::MANAGE_DOORS]);
$presenter = new DeleteDoorAPIPresenter();
$doorDelyeeter->delete($doorId, $presenter);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment