/**
  * Authorize the page.
  *
  * @param PageInterface $page
  */
 public function authorize(PageInterface $page)
 {
     /* @var UserInterface $user */
     $user = $this->guard->user();
     /**
      * If the page is not enabled and we
      * are not logged in then 404.
      */
     if (!$page->isEnabled() && !$user) {
         abort(404);
     }
     /**
      * If the page is not enabled and we are
      * logged in then make sure we have permission.
      */
     if (!$page->isEnabled()) {
         $this->authorizer->authorize('anomaly.module.pages::view_drafts');
     }
     /**
      * If the page is restricted to specific
      * roles then make sure our user is one of them.
      */
     $allowed = $page->getAllowedRoles();
     if (!$allowed->isEmpty() && (!$user || !$user->hasAnyRole($allowed))) {
         $page->setResponse($this->response->redirectTo('login'));
     }
 }
 /**
  * Handle the command.
  *
  * @param ResponseFactory $response
  * @param Request         $request
  */
 public function handle(ResponseFactory $response, Request $request)
 {
     /* @var TableBuilder $builder */
     foreach ($this->builder->getTables() as $builder) {
         $builder->post();
     }
     if (!$this->builder->getTableResponse()) {
         $this->builder->setTableResponse($response->redirectTo($request->fullUrl()));
     }
 }
Example #3
0
 /**
  * Handle the command.
  *
  * @param  Request         $request
  * @param  ResponseFactory $response
  * @throws \Exception
  */
 public function handle(Request $request, ResponseFactory $response)
 {
     if ($this->builder instanceof MultipleTableBuilder) {
         return;
     }
     $this->dispatch(new ExecuteAction($this->builder));
     if (!$this->builder->getTableResponse()) {
         $this->builder->setTableResponse($response->redirectTo($request->fullUrl()));
     }
 }
Example #4
0
 /**
  * Create a new redirect response to the given path.
  *
  * @param string $path
  * @param int $status
  * @param array $headers
  * @param bool|null $secure
  * @return \Illuminate\Http\RedirectResponse 
  * @static 
  */
 public static function redirectTo($path, $status = 302, $headers = array(), $secure = null)
 {
     return \Illuminate\Routing\ResponseFactory::redirectTo($path, $status, $headers, $secure);
 }