/**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $projectId = $request->route('id') ? $request->route('id') : $request->route('project');
     if ($this->service->checkProjectOwner($projectId) == false) {
         return Response::json(['error' => true, 'message' => "Você não tem permissão de owner neste projeto!"], 400);
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $projectId = $request->route('id') ? $request->route('id') : $request->route('project');
     if ($this->service->checkProjectOwner($projectId) == false) {
         return ['error' => 'Access forbiden'];
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     $projectId = $request->route("id") ? $request->route("id") : $request->route("project");
     if ($this->service->checkProjectOwner($projectId) == false && $this->service->checkProjectPermissions($projectId) == false) {
         return response(['message' => 'User don\'t have access to project'], 403);
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     $projectId = $request->route("id") ? $request->route("id") : $request->route("project");
     if (!$this->service->checkProjectOwner($projectId)) {
         return response(['message' => 'User don\'t have access to project'], 403);
         /*
                     return [ "code" => 403,
                "error" => "Access forbidden."
                ];
         * 
         */
     }
     return $next($request);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     if ($this->service->checkProjectOwner($id) == false) {
         return ['error' => 'Access Forbidden'];
     }
     return $this->service->update($request->all(), $id);
 }
 private function checkProjectNotePermissions($projectId)
 {
     if ($this->projectService->checkProjectOwner($projectId) or $this->projectService->checkProjectMember($projectId)) {
         return true;
     }
     return false;
 }
 /**
  * Remove a project member
  * @param  Request $request form request
  * @param  integer  $id      project id
  * @param  integer  $userId  user id
  * @return Response
  */
 public function removeMember(Request $request, $id, $userId)
 {
     if (!$this->service->checkProjectOwner($id)) {
         return ['error' => 'Access Forbidden'];
     }
     return $this->service->removeMember($id, $userId);
 }
 /**
  * @param $id
  * @param $fileId
  *
  * @return array
  */
 public function destroy($id, $fileId)
 {
     if (empty($id) or $this->projectService->checkProjectOwner($id) == false) {
         return ['error' => 'Access forbidden'];
     }
     return $this->service->destroy($id, $fileId);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $projectId = $request->route('id') ? $request->route('id') : $request->route('project');
     if ($this->service->checkProjectOwner($projectId) == false) {
         return ['error' => 'Access forbiden'];
     }
     return $next($request);
     /*
     $userId = \Authorizer::getResourceOwnerId();
     $projectId = $request->project;
     
     if($this->repository->isOwner($projectId, $userId) == false){
         return ['error' => 'Access forbidden'];
     }
     
     return $next($request);
     */
 }
 public function removeTask($project_id, $task_id)
 {
     try {
         if (!$this->service->checkProjectOwner($project_id)) {
             return $this->erroMsgm("O usuário não é owner desse projeto");
         }
         $this->taskRepository->find($task_id)->delete();
         return ['success' => true, 'message' => 'Tarefa deletada com sucesso!'];
     } catch (QueryException $e) {
         return $this->erroMsgm('Tarefa não pode ser apagado pois existe um projeto vinculado a ela.');
     } catch (ModelNotFoundException $e) {
         return $this->erroMsgm('Tarefa não encontrada.');
     } catch (\Exception $e) {
         return $this->erroMsgm('Ocorreu um erro ao excluir a tarefa.');
     }
 }