Пример #1
0
 /**
  * Garbage collect activations and reminders.
  *
  * @param SecurityApi                  $security
  * @param SecurityContextConfiguration $configuration
  */
 protected function garbageCollect(SecurityApi $security, SecurityContextConfiguration $configuration)
 {
     try {
         $activations = $security->activations();
         $reminders = $security->reminders();
         $this->sweep($activations, $configuration->getActivationsLottery());
         $this->sweep($reminders, $configuration->getRemindersLottery());
     } catch (\Exception $e) {
         // Silently fail and report, but still serve the content.
         $this->logger->error("Unable to garbage collect reminders or activations: " . $e->getMessage(), $e->getTrace());
     }
 }
 /**
  * Check if the logged user has access to the given permission(s).
  * Users must implement the Digbang\Security\Permissions\Permissible interface.
  *
  * @param string|array $permission
  *
  * @return void
  * @throws Unauthorized
  */
 private function checkPermission($permission)
 {
     if (!$permission) {
         return;
     }
     $user = $this->securityApi->getUser(true);
     if ($user instanceof Permissible && $user->hasAccess($permission)) {
         return;
     }
     throw Unauthorized::permissionDenied($permission, $this->securityApi);
 }