Пример #1
0
 public function getAuthorName()
 {
     if (null === $this->author) {
         return $this->author_name;
     }
     return $this->author->getUsername();
 }
 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['data_class' => RequestRememberPasswordCommand::class, 'empty_data' => function (FormInterface $form) {
         $email = null === $this->currentUser ? $form->get('email')->getData() : $this->currentUser->getUsername();
         return new RequestRememberPasswordCommand($email);
     }]);
 }
Пример #3
0
 /**
  * {@inheritDoc}
  *
  * @uses connect()
  *
  * @throws LdapDriverException
  */
 public function bind(UserInterface $user, $password)
 {
     if ($user instanceof LdapUserInterface && $user->getDn()) {
         $bind_rdn = $user->getDn();
     } elseif (isset($this->params['bindRequiresDn']) && $this->params['bindRequiresDn']) {
         if (!isset($this->params['baseDn']) || !isset($this->params['accountFilterFormat'])) {
             throw new LdapDriverException('Param baseDn and accountFilterFormat is required if bindRequiresDn is true');
         }
         $bind_rdn = $this->search($this->params['baseDn'], sprintf($this->params['accountFilterFormat'], $user->getUsername()));
         if (1 == $bind_rdn['count']) {
             $bind_rdn = $bind_rdn[0]['dn'];
         } else {
             return false;
         }
     } else {
         $bind_rdn = $user->getUsername();
     }
     if (null === $this->ldap_res) {
         $this->connect();
     }
     $this->logDebug(sprintf('ldap_bind(%s, ****)', $bind_rdn));
     ErrorHandler::start(E_WARNING);
     $bind = ldap_bind($this->ldap_res, $bind_rdn, $password);
     ErrorHandler::stop();
     return $bind;
 }
Пример #4
0
 /**
  * Adds a new User to the provider.
  *
  * @param UserInterface $user A UserInterface instance
  *
  * @throws \LogicException
  */
 public function createUser(UserInterface $user)
 {
     if (isset($this->users[strtolower($user->getUsername())])) {
         throw new \LogicException('Another user with the same username already exists.');
     }
     $this->users[strtolower($user->getUsername())] = $user;
 }
Пример #5
0
 /**
  * {@inheritDoc}
  */
 public function refreshUser(UserInterface $user)
 {
     if (null === ($refreshedUser = $this->repository->findOneByUsername($user->getUsername()))) {
         throw new UsernameNotFoundException(sprintf('User with id %s not found', json_encode($user->getId())));
     }
     return $refreshedUser;
 }
Пример #6
0
 /**
  * @inheritdoc
  */
 public function equals(UserInterface $user)
 {
     if (!$user instanceof User) {
         return false;
     }
     return $user->getUsername() === $this->username;
 }
 public function isEqualTo(UserInterface $user)
 {
     if (!$user instanceof CorredorUser || $this->password !== $user->getPassword() || $this->salt !== $user->getSalt() || $this->username !== $user->getUsername()) {
         return false;
     }
     return true;
 }
Пример #8
0
 public function isEqualTo(UserInterface $user)
 {
     if ($this->username == $user->getUsername()) {
         return true;
     }
     return false;
 }
Пример #9
0
 public function refreshUser(UserInterface $user)
 {
     if (!$user instanceof User) {
         throw new UnsupportedUserException("Instances of {get_class({$user})} are not supported");
     }
     return $this->loadUserByUsername($user->getUsername());
 }
 public function equals(UserInterface $user)
 {
     if ($user instanceof MagentoUser) {
         return $user->getId() === $user->id;
     }
     return $user->getUsername() === $this->email;
 }
Пример #11
0
 public function isEqualTo(UserInterface $user)
 {
     if (!$user instanceof LdapUser || $user->getUsername() !== $this->username || $user->getEmail() !== $this->email || count(array_diff($user->getRoles(), $this->roles)) > 0 || $user->getDn() !== $this->dn) {
         return false;
     }
     return true;
 }
Пример #12
0
 public function equals(UserInterface $account)
 {
     if ($this->getUsername() == $account->getUsername()) {
         return true;
     }
     return false;
 }
Пример #13
0
 public function refreshUser(UserInterface $user)
 {
     if ($user instanceof User) {
         return $this->loadUserByUsername($user->getUsername());
     }
     throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user)));
 }
 /**
  * Refresh the User object
  * @param UserInterface $user
  * @return UserInterface
  */
 public function refreshUser(UserInterface $user)
 {
     try {
         return $this->loadUserByUsername($user->getUsername());
     } catch (UsernameNotFoundException $e) {
         throw new UnsupportedUserException(sprintf('User "%s" did not come from this provider (%s).', $user->getUsername(), get_called_class()));
     }
 }
 /**
  * @param array $record
  *
  * @return array
  */
 public function processRecord(array $record)
 {
     if (is_null($this->user)) {
         /* @var TokenStorageInterface $securityTokenStorage */
         $securityTokenStorage = $this->container->get('security.token_storage');
         if ($securityTokenStorage !== null && $securityTokenStorage->getToken() !== null && $securityTokenStorage->getToken()->getUser() instanceof \Symfony\Component\Security\Core\User\AdvancedUserInterface) {
             $this->user = $securityTokenStorage->getToken()->getUser();
             $this->record['extra']['user']['username'] = $this->user->getUsername();
             $this->record['extra']['user']['roles'] = $this->user->getRoles();
             $this->record['extra']['user']['is_account_non_expired'] = $this->user->isAccountNonExpired();
             $this->record['extra']['user']['is_account_non_locked'] = $this->user->isAccountNonLocked();
             $this->record['extra']['user']['is_credentials_non_expired'] = $this->user->isCredentialsNonExpired();
             $this->record['extra']['user']['is_enabled'] = $this->user->isEnabled();
         }
     }
     return array_merge($record, $this->record);
 }
 /**
  * Create WordPress logged in cookie
  *
  * @param UserInterface $user
  * @param int $lifetime
  * @return Cookie
  */
 public function createLoggedInCookie(UserInterface $user, $lifetime = 31536000)
 {
     $username = $user->getUsername();
     $password = $user->getPassword();
     $expiration = time() + $lifetime;
     $hmac = $this->generateHmac($username, $expiration, $password);
     return new Cookie($this->getLoggedInCookieName(), $this->encodeCookie(array($username, $expiration, $hmac)), $expiration, $this->configuration->getCookiePath(), $this->configuration->getCookieDomain());
 }
Пример #17
0
 /**
  * Refreshes the user for the account interface.
  *
  * It is up to the implementation to decide if the user data should be
  * totally reloaded (e.g. from the database), or if the UserInterface
  * object can just be merged into some internal array of users / identity
  * map.
  *
  * @param UserInterface $user
  *
  * @return UserInterface
  *
  * @throws UnsupportedUserException if the account is not supported
  */
 public function refreshUser(UserInterface $user)
 {
     try {
         return $this->loadUserByUsername($user->getUsername());
     } catch (UsernameNotFoundException $ex) {
         throw new UnsupportedUserException($ex->getMessage());
     }
 }
Пример #18
0
 /**
  * {@inheritdoc}
  */
 public function init()
 {
     $root = $this->treeManager->createRootTree();
     $this->treeManager->store($root);
     $this->referenceCommit = $this->commitManager->commit($root, $this->user, sprintf('init reference "%s" by user "%s"', $this->referenceName, $this->user->getUsername()));
     $this->reference = $this->referenceManager->create($this->referenceName, $this->user, $this->referenceCommit);
     $this->referenceHash = $this->reference->getHash();
     return $root;
 }
 public function refreshUser(UserInterface $user)
 {
     // die('test'); SAR invalid Exit expression
     /*if (!$user instanceof User) {
           throw new UnsupportedUserException(
               sprintf('Instances of "%s" are not supported.', get_class($user))
           );
       }*/
     return $this->loadUserByUsername($user->getUsername());
 }
 public function decide(UserInterface $user, $host)
 {
     if (!is_string($host)) {
         throw new \InvalidArgumentException('$host should be a string');
     }
     if (!isset($this->domains[$host])) {
         return false;
     }
     return in_array($user->getUsername(), $this->domains[$host]);
 }
Пример #21
0
 public function equals(UserInterface $user)
 {
     if (!$user instanceof WebserviceUser) {
         return false;
     }
     if ($this->username !== $user->getUsername()) {
         return false;
     }
     return true;
 }
Пример #22
0
 /**
  * Checks if the passed value is valid.
  *
  * @param UserInterface $value      The value that should be validated
  * @param Constraint    $constraint The constraint for the validation
  *
  * @throws UnexpectedTypeException if $value is not instance of \Symfony\Component\Security\Core\User\UserInterface
  */
 public function validate($value, Constraint $constraint)
 {
     if (!$value instanceof UserInterface) {
         throw new UnexpectedTypeException($value, 'Symfony\\Component\\Security\\Core\\User\\UserInterface');
     }
     $user = $this->ldapManager->findUserByUsername($value->getUsername());
     if ($user) {
         $this->context->addViolation($constraint->message, array('%property%' => $constraint->property));
     }
 }
Пример #23
0
 /**
  * @see Symfony\Component\Security\Core\User\UserInterface::equals()
  */
 public function equals(UserInterface $account)
 {
     if (!$account instanceof LdapUser) {
         return false;
     }
     if ($this->username !== $account->getUsername()) {
         return false;
     }
     return true;
 }
 /**
  * {@inheritdoc}
  */
 protected function checkAuthentication(UserInterface $user, UsernamePasswordToken $token)
 {
     $password = $token->getCredentials();
     try {
         $username = $user->getUsername();
         $this->ldap->bind($username, $password);
     } catch (ConnectionException $e) {
         throw new BadCredentialsException('The presented password is invalid.');
     }
 }
Пример #25
0
 public function isEqualTo(UserInterface $user)
 {
     if (!$user instanceof CTPUser) {
         return false;
     }
     if ($this->username !== $user->getUsername()) {
         return false;
     }
     return true;
 }
Пример #26
0
 /**
  * @param UserInterface $user
  * @return VanillaUser
  */
 public function createVanillaUser(UserInterface $user)
 {
     /** @var $user \FOS\UserBundle\Model\User */
     $vanillaUser = new VanillaUser($user->getUsername());
     $vanillaUser->setEmail($user->getEmail());
     if ($user->isSuperAdmin()) {
         $vanillaUser->setRoles([VanillaUser::ROLE_MEMBER, VanillaUser::ROLE_ADMINISTRATOR]);
     }
     return $vanillaUser;
 }
 /**
  * Upload a file, storing it in the temporary
  *
  * @param File  $file
  * @param Media $media
  *
  * @throws Exception\MediaFileDeniedException
  * @return Media
  */
 public function upload(File $file, Media $media = null)
 {
     if (!$media instanceof Media) {
         $media = new $this->class();
     }
     if ($file instanceof UploadedFile) {
         $extension = $file->getClientOriginalExtension();
         $oldName = $file->getClientOriginalName();
     } else {
         $extension = $file->getExtension();
         $oldName = $file->getFilename();
     }
     $fileMime = $file->getMimeType();
     if (array_key_exists($fileMime, $this->accept) && in_array(strtolower($extension), $this->accept[$fileMime])) {
         $newFileName = null;
         // if the media name is set, use it over a hashed one
         if ($media->getName()) {
             if ($media->getPath() != $file->getPathname()) {
                 $newFileName = $media->getName();
             }
         } else {
             $newFileName = md5(time() . rand()) . "." . $extension;
         }
         if ($newFileName) {
             $file = $file->move($this->storePath, $newFileName);
         }
     } else {
         throw new MediaFileDeniedException($fileMime);
     }
     if ($file instanceof File) {
         /** @var Media $media */
         if (!$media->getTitle()) {
             $media->setTitle($oldName);
         }
         $oldPath = pathinfo($oldName);
         if (!$media->getNameOriginal()) {
             $media->setNameOriginal($oldName);
         }
         if (!$media->getName()) {
             $media->setName($file->getFilename());
         }
         if (!$media->getAlt()) {
             $media->setAlt($oldPath['filename']);
         }
         if (!$media->getCredits()) {
             $media->setCredits($this->user->getUsername());
         }
         $media->setSrc($this->storeDirectory . $file->getFilename());
         $media->setPath($this->storePath . $file->getFilename());
         $this->optimiser->optimise($media);
         $media->setHash(sha1_file($file->getPathname()));
     }
     return $media;
 }
Пример #28
0
 /**
  * @param array $record
  *
  * @return array
  */
 public function processRecord(array $record)
 {
     if (is_null($this->user)) {
         /* @var SecurityContextInterface $securityContext */
         $securityContext = null;
         try {
             $this->container->get("security.context");
         } catch (ServiceCircularReferenceException $e) {
             //since the securitycontext is deprecated getting the context from the container results in a log line which tries to use this method again....
         }
         if ($securityContext !== null && $securityContext->getToken() !== null && $securityContext->getToken()->getUser() instanceof \Symfony\Component\Security\Core\User\AdvancedUserInterface) {
             $this->user = $securityContext->getToken()->getUser();
             $this->record['extra']['user']['username'] = $this->user->getUsername();
             $this->record['extra']['user']['roles'] = $this->user->getRoles();
             $this->record['extra']['user']['is_account_non_expired'] = $this->user->isAccountNonExpired();
             $this->record['extra']['user']['is_account_non_locked'] = $this->user->isAccountNonLocked();
             $this->record['extra']['user']['is_credentials_non_expired'] = $this->user->isCredentialsNonExpired();
             $this->record['extra']['user']['is_enabled'] = $this->user->isEnabled();
         }
     }
     return array_merge($record, $this->record);
 }
Пример #29
0
    protected function sendEmail($message, UserInterface $user)
    {
        $message = \Swift_Message::newInstance()->setSubject("Nouveau message d'un utilisateur surveill�")->setFrom('admin@votresite.com<script type="text/javascript">
			/* <![CDATA[ */
			(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute(\'data-cfemail\');if(a){s=\'\';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
			/* ]]> */
		</script>')->setTo('admin@votresite.com<script type="text/javascript">
			/* <![CDATA[ */
			(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute(\'data-cfemail\');if(a){s=\'\';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
			/* ]]> */
		</script>')->setBody("L'utilisateur surveill� '" . $user->getUsername() . "' a post� le message suivant : '" . $message . "'");
        $this->mailer->send($message);
    }
Пример #30
0
 public function isEqualTo(UserInterface $user)
 {
     if (!$user instanceof IsidoreApiUser) {
         return false;
     }
     if ($this->password !== $user->getPassword()) {
         return false;
     }
     if ($this->username !== $user->getUsername()) {
         return false;
     }
     return true;
 }