Beispiel #1
0
 /**
  * Displays an _available websites_ form on {@link WebsiteAdminNotAccessible}.
  *
  * @param \ICanboogie\Exception\RescueEvent $event
  * @param WebsiteAdminNotAccessible $target
  */
 public static function on_website_admin_not_accessible_rescue(\ICanboogie\Exception\RescueEvent $event, WebsiteAdminNotAccessible $target)
 {
     global $core;
     $block = $core->modules['users']->getBlock('available-sites');
     $document = new \Icybee\DocumentDecorator(new \Icybee\AdminDecorator($block));
     $event->response = new Response((string) $document, $target->getCode(), ['Content-Type' => 'text/html; charset=utf-8']);
     $event->stop();
 }
Beispiel #2
0
 public static function on_exception_rescue(RescueExceptionEvent $event)
 {
     $event->chain(function (RescueExceptionEvent $event, $target) {
         if ($event->response) {
             return;
         }
         try {
             $sunshine = new ExceptionSunshine($target);
             $html = \ICanBoogie\app()->render($sunshine, ['layout' => '@exception']);
             $event->response = new Response($html, $sunshine->http_code, ['X-Exception-Origin' => $sunshine->file]);
         } catch (\Exception $e) {
         }
     });
 }
Beispiel #3
0
 /**
  * Displays a login form on {@link SecurityException}.
  *
  * @param \ICanBoogie\Exception\RescueEvent $event
  * @param SecurityException $target
  */
 public static function on_security_exception_rescue(\ICanBoogie\Exception\RescueEvent $event, SecurityException $target)
 {
     global $core;
     $request = $event->request;
     if ($request->context->dispatcher instanceof \ICanBoogie\Operation\Dispatcher && $request->is_xhr) {
         return;
     }
     if ($target instanceof PermissionRequired || \ICanBoogie\Routing\decontextualize($request->normalized_path) != '/admin/') {
         \ICanBoogie\log_error($target->getMessage());
     }
     $block = $core->modules['users']->getBlock('connect');
     $document = new \Icybee\DocumentDecorator(new \Icybee\AdminDecorator($block));
     $document->body->add_class('page-slug-authenticate');
     $event->response = new Response((string) $document, $target->getCode(), ['Content-Type' => 'text/html; charset=utf-8']);
     $event->stop();
 }
 public static function on_operation_failure_rescue(\ICanBoogie\Exception\RescueEvent $event, \ICanBoogie\Operation\Failure $target)
 {
     global $core;
     $operation = $target->operation;
     if (!$operation instanceof NonceLoginOperation) {
         return;
     }
     if (!$event->request['token']) {
         return;
     }
     $errors = $operation->response->errors;
     if (!$errors['token']) {
         return;
     }
     $redirect_to = $core->site->resolve_view_url('users/nonce_login_request');
     if (!$redirect_to) {
         return;
     }
     $event->response = new RedirectResponse($redirect_to);
     $event->stop();
 }