Example #1
0
File: Auth.php Project: zfury/cmf
 /**
  * @param \User\Entity\User $user
  * @param $password
  * @return \User\Entity\Auth
  */
 public function generateEquals(\User\Entity\User $user, $password)
 {
     //delete row
     $auth = $this->getObjectManager()->getRepository('User\\Entity\\Auth')->findOneBy(['userId' => $user->getId(), 'provider' => Auth::PROVIDER_EQUALS]);
     //            ->findOneByUserId($user->getId());
     if ($auth) {
         $this->getObjectManager()->remove($auth);
         $this->getObjectManager()->flush();
     }
     // new auth row
     $row = new \User\Entity\Auth();
     $row->setUserId($user->getId());
     $row->setForeignKey($user->getEmail());
     $row->setProvider(self::PROVIDER_EQUALS);
     $row->setTokenType(self::TYPE_ACCESS);
     // generate secret
     $alpha = range('a', 'z');
     shuffle($alpha);
     $secret = array_slice($alpha, 0, rand(5, 15));
     $secret = md5($user->getId() . join('', $secret));
     $row->setTokenSecret($secret);
     // encrypt password and save as token
     $row->setToken(self::encrypt($row, $password));
     $user->getAuths()->add($row);
     $row->setUser($user);
     $this->getObjectManager()->persist($row);
     $this->getObjectManager()->flush();
     return $row;
 }
 public function __invoke(User $user, $options, $attributes, $link = false)
 {
     /** @var Gravatar $gravatar */
     $gravatar = $this->getView()->plugin('gravatar');
     $picture = $gravatar($user->getEmail(), $options, $attributes)->getImgTag();
     if (!$link) {
         return $picture;
     }
     $url = $this->getView()->plugin('url');
     $href = $url('user/view', array('id' => $user->getId()));
     return sprintf('<a class="user-view" href="%s">%s</a>', $href, $picture);
 }
Example #3
0
File: User.php Project: zfury/cmf
 /**
  * @param Entity\User $user
  * @param $content
  * @return mixed
  */
 public function forgotPasswordpMail(\User\Entity\User $user, $content)
 {
     $transport = $this->getServiceLocator()->get('mail.transport');
     $text = new MimePart($content);
     $text->type = Mime::TYPE_TEXT;
     $text->charset = "UTF-8";
     $html = new MimePart($content);
     $html->type = Mime::TYPE_HTML;
     $html->encoding = Mime::ENCODING_BASE64;
     $html->charset = "UTF-8";
     $body = new MimeMessage();
     $body->setParts([$text, $html]);
     /**
      * @var \Zend\Mail\Message $message
      */
     $message = $this->getServiceLocator()->get('mail.message');
     $message->addTo($user->getEmail())->setSubject("Password recovery")->setBody($body);
     return $transport->send($message);
 }
 /**
  * {@inheritDoc}
  */
 public function getEmail()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getEmail', array());
     return parent::getEmail();
 }
Example #5
0
File: Mail.php Project: zfury/cmf
 /**
  * @param \Mail\Entity\Mail $template
  * @param \User\Entity\User $user $user
  * @return \Zend\Mail\Message
  */
 public function prepareMessage($template, $user)
 {
     $message = $this->getServiceLocator()->get('mail.message');
     $message->setFrom($template->getFromEmail(), $template->getFromName())->setTo($user->getEmail())->setSubject($template->getSubject())->setBody($this->prepareBody($template));
     return $message;
 }
Example #6
0
 protected function sendPasswordLinkEmail(User $user)
 {
     /* @var $mailService \Application\Service\MailService */
     $mailService = $this->locator->get('Application\\Service\\Mail');
     /* @var $urlHelper \Zend\View\Helper\Url */
     $urlHelper = $this->locator->get('Zend\\View\\Renderer\\PhpRenderer')->getHelperPluginManager()->get('url');
     $message = new Message();
     $message->setTo($user->getEmail(), $user->getDisplayName());
     $message->setFrom($this->getConfig()->siteInfo->emailInfo->email, $this->getConfig()->siteInfo->emailInfo->name);
     $message->setSubject('Parooli unustamine');
     $message->setBody('Parooli uuendamiseks vajutage järgnevale lingile ' . $urlHelper->__invoke('user/default', array('controller' => 'index', 'action' => 'newPassword', 'hash' => $user->getHash()->getHash()), array('force_canonical' => true)));
     $mailService->send($mailService->getTransport(), $message);
 }