/** * @param \TYPO3\Flow\Security\Account $account * @return string */ public function generateDisqusRemoteAuth(\TYPO3\Flow\Security\Account $account) { /** @var \TYPO3\Party\Domain\Model\Person $person */ $person = $account->getParty(); $data = array('id' => $account->getAccountIdentifier(), 'username' => $person->getName()->getFullName(), 'email' => $person->getPrimaryElectronicAddress()->getIdentifier(), 'avatar' => sprintf('//typo3.org/services/userimage.php?username=%s&size=big', $account->getAccountIdentifier())); if (!isset($this->settings['disqusApiSecret'])) { throw new \InvalidArgumentException('You need to set up a disqusApiSecrect in your settings.', 1425572965); } $message = base64_encode(json_encode($data)); $timestamp = time(); $apiSecret = $this->settings['disqusApiSecret']; $hmac = $this->disqusHmacSha1($message . ' ' . $timestamp, $apiSecret); return $message . ' ' . $hmac . ' ' . $timestamp; }
/** * @expectedException \TYPO3\Flow\Security\Exception * @expectedExceptionCode 1397747246 * @test */ public function callingGetPartyWithoutIdentifierThrowsException() { $account = new Account(); $account->getParty(); }
/** * @param Account $account * @param NodeInterface $userStorageNode * @param PersonDto $person * @return NodeInterface|string */ protected function createProfileNode(Account $account, NodeInterface $userStorageNode, PersonDto $person) { try { $profileNode = $this->findProfileNode($person->getEmailAddress()); if ($profileNode === NULL) { $properties = ['title' => $person->getFirstName() . ' ' . $person->getLastName(), 'firstName' => $person->getFirstName(), 'lastName' => $person->getLastName(), 'address' => $person->getAddress(), 'zipCode' => $person->getZipCode(), 'city' => $person->getCity(), 'emailAddress' => $person->getEmailAddress(), 'phone' => $person->getPhone(), 'dateOfBirth' => $person->getDateOfBirth(), 'jiuJitsu' => $person->getJiuJitsu(), 'buJitsuDo' => $person->getBuJitsuDo(), 'jiuJitsuDegree' => $person->getJiuJitsuDegree(), 'buJitsuDoDegree' => $person->getBuJitsuDoDegree(), 'gender' => $person->getGender()]; if ($person->getFirstName() && $person->getLastName()) { $nodeName = $person->getFirstName() . ' ' . $person->getLastName(); } $idealNodeName = Utility::renderValidNodeName(isset($nodeName) ? $nodeName : uniqid('node')); $idealNodeName = htmlspecialchars($idealNodeName, ENT_NOQUOTES, 'UTF-8'); $profileNode = $this->nodeWriteRepository->createChildNode($userStorageNode, $idealNodeName, 'BuJitsuDo.Authentication:Person', $properties); if ($person->getImage() instanceof Image) { $profileNode = $this->profileService->setImageToNode($profileNode, $person->getImage(), $person->getFirstName(), 'Profile images'); } } $account->getParty()->getPreferences()->set('profileNodeIdentifier', $profileNode->getIdentifier()); $this->partyRepository->update($account->getParty()); $this->persistenceManager->persistAll(); $this->emitPersonCreated($profileNode); return $profileNode; } catch (\Exception $exception) { $this->systemLogger->log('Profile node could not be created because: ' . $exception->getMessage(), LOG_CRIT); return $exception->getMessage(); } }
/** * {@inheritDoc} */ public function getParty() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getParty', array()); return parent::getParty(); }
/** * Persists new Account. * * @param Account $account * * @return void */ public function finalizePersistingNewUser(Account $account) { $party = $account->getParty(); if ($party instanceof AbstractParty) { $this->partyRepository->add($party); } $this->accountRepository->add($account); $this->persistenceManager->persistAll(); }