コード例 #1
0
 /**
  * Get authentication
  *
  * @param boolean $isConfirmRequest
  *
  * @return void
  */
 protected function authenticate($isConfirmRequest = FALSE)
 {
     $code = $this->getAuthCode();
     /* @var $subscriber Subscriber */
     $subscriber = $this->subscriberRepository->findByCode($code, !$isConfirmRequest);
     if ($subscriber === NULL) {
         $this->processError('authFailed');
     }
     $modify = '+1 hour';
     if (isset($this->settings['subscriptionManager']['subscriber']['emailHashTimeout'])) {
         $modify = trim($this->settings['subscriptionManager']['subscriber']['emailHashTimeout']);
     }
     if ($subscriber->isAuthCodeExpired($modify)) {
         $this->processError('linkOutdated');
     }
     if ($isConfirmRequest === TRUE) {
         $confirmedSubscriptions = $this->subscriberRepository->findExistingSubscriptions($subscriber->getPostUid(), $subscriber->getEmail(), $subscriber->getUid());
         if (count($confirmedSubscriptions) > 0) {
             $subscriber->_setProperty('deleted', TRUE);
             $this->subscriberRepository->update($subscriber);
             $this->persistEntities();
             $this->processError('alreadyRegistered', FlashMessage::NOTICE);
         }
     }
     $this->authentication->login($subscriber->getEmail());
     $this->subscriber = $subscriber;
 }
コード例 #2
0
 /**
  * Checks if a new subscription should be added
  *
  * @param Comment $comment
  *
  * @return boolean
  */
 protected function isNewSubscriptionValid(Comment $comment)
 {
     if (!$this->settings['blogsystem']['comments']['subscribeForComments'] || !$comment->getSubscribe()) {
         return FALSE;
     }
     // check if user already registered
     $subscribers = $this->subscriberRepository->findExistingSubscriptions($comment->getPostId(), $comment->getEmail());
     if (count($subscribers) > 0) {
         $this->log->notice('Subscriber [' . $comment->getEmail() . '] already registered.');
         return FALSE;
     }
     return TRUE;
 }