Beispiel #1
0
 /**
  * Sets the user identity.
  * @param \Nette\Security\IIdentity $identity
  * @return UserStorage Provides a fluent interface
  */
 public function setIdentity(IIdentity $identity = null)
 {
     if ($identity !== null) {
         $identity = new FakeIdentity($identity->getId());
     }
     return parent::setIdentity($identity);
 }
Beispiel #2
0
 public function setIdentity(IIdentity $identity = null)
 {
     if ($identity instanceof UserAggregate) {
         $identity = new Identity(get_class($identity), [], ['id' => $identity->getId()]);
     }
     return parent::setIdentity($identity);
 }
Beispiel #3
0
 /**
  * @param \Nette\Security\IIdentity
  * @return UserStorage
  */
 public function setIdentity(IIdentity $identity = NULL)
 {
     if (!($identity instanceof User || $identity === NULL)) {
         throw new InvalidArgumentException(__CLASS__ . '::' . __METHOD__ . ' needs instance of ' . User::class . ', got ' . get_class($identity));
     }
     $this->identity = $identity;
     return parent::setIdentity($identity === NULL ? NULL : new Identity($identity->getId()));
 }
Beispiel #4
0
 /**
  * Sets the user identity.
  * @param Nette\Security\IIdentity $identity
  * @return Storage
  */
 public function setIdentity(Nette\Security\IIdentity $identity = NULL)
 {
     if (!is_null($identity)) {
         $identity->browser = $this->browser->getName();
         $identity->browserVersion = $this->browser->getVersion();
         $identity->hash = $this->identityHash->createIdentityHash($identity->getId(), $this->request->getRemoteAddress());
     }
     return parent::setIdentity($identity);
 }
 /**
  * Sets the user identity.
  * @return UserStorage Provides a fluent interface
  */
 public function setIdentity(IIdentity $identity = null)
 {
     if ($identity !== NULL) {
         $class = get_class($identity);
         // we want to convert identity entities into fake identity
         // so only the identifier fields are stored,
         // but we are only interested in identities which are correctly
         // mapped as doctrine entities
         if ($this->entityManager->getMetadataFactory()->hasMetadataFor($class)) {
             $cm = $this->entityManager->getClassMetadata($class);
             $identifier = $cm->getIdentifierValues($identity);
             $identity = new FakeIdentity($identifier, $class);
         }
     }
     return parent::setIdentity($identity);
 }