Ejemplo n.º 1
0
 /**
  * Check if there is a valid authorisation session.
  *
  * @return boolean
  */
 public function hasAuthorisation()
 {
     if ($this->authorisation === null) {
         $this->getAuthorisation();
     }
     if ($this->authorisation !== null && !$this->authorisation->getAccount()->isEnabled()) {
         return false;
     }
     return (bool) $this->authorisation ?: false;
 }
Ejemplo n.º 2
0
 /**
  * Dispatch event to any listeners.
  *
  * @param string        $type          Either MembersEvents::MEMBER_LOGIN' or MembersEvents::MEMBER_LOGOUT
  * @param Authorisation $authorisation
  */
 protected function dispatchEvent($type, Authorisation $authorisation)
 {
     if (!$this->dispatcher->hasListeners($type)) {
         return;
     }
     $event = new MembersLoginEvent();
     $event->setAccount($authorisation->getAccount());
     try {
         $this->dispatcher->dispatch($type, $event);
     } catch (\Exception $e) {
         if ($this->config->isDebug()) {
             dump($e);
         }
         $this->logger->critical('Members event dispatcher had an error', ['event' => 'exception', 'exception' => $e]);
     }
 }