/** * @return NodeInterface */ public function getCurrentUserNode() { try { return $this->profileService->getCurrentPartyProfile(); } catch (\Exception $exception) { $this->systemLogger->log('Profile node could not be fetched: ' . $exception->getMessage(), LOG_CRIT); } }
/** * @Flow\SkipCsrfProtection * @return void|string */ public function authenticateAction() { try { $this->authenticationManager->authenticate(); if ($this->authenticationManager->isAuthenticated()) { $profile = $this->profileService->getCurrentPartyProfile(); $this->redirect('show', 'Frontend\\Node', 'TYPO3.Neos', ['node' => $profile->getPath()]); } else { $this->addFlashMessage('Gebruikersnaam of wachtwoord is niet correct'); $this->forwardToReferringRequest(); } } catch (\Exception $e) { $this->addFlashMessage('Gebruikersnaam of wachtwoord is niet correct'); $this->forwardToReferringRequest(); } }
/** * @param string $personIdentifier * @param Context $context * * @throws \Exception * * @return NodeInterface */ protected function getPersonProfile($personIdentifier, Context $context) { if ($personIdentifier === '') { $person = $this->profileService->getCurrentPartyProfile(); } else { $person = $context->getNodeByIdentifier($personIdentifier); } return $person; }
/** * Check if user is already registered for an event. * * @param NodeInterface $event * @param NodeInterface $person * * @return string */ public function render(NodeInterface $event, NodeInterface $person = null) { $authenticationProviderName = $this->authenticationManagerInterface->getSecurityContext()->getAccount()->getAuthenticationProviderName(); if ($authenticationProviderName === 'Typo3BackendProvider') { return $this->renderElseChild(); } if ($person === null) { $person = $this->profileService->getCurrentPartyProfile(); } $eventAttendees = $event->getProperty('attendees') ? $event->getProperty('attendees') : []; $eventAttendeesIdentifiers = []; foreach ($eventAttendees as $eventAttendee) { /* @var NodeInterface $eventAttendee */ $eventAttendeesIdentifiers[] = $eventAttendee->getIdentifier(); } if (in_array($person->getIdentifier(), $eventAttendeesIdentifiers, true)) { return $this->renderThenChild(); } return $this->renderElseChild(); }
/** * @param ImageDto $imageDto * @param string $profileNodeIdentifier * @throws UpdateNodeException * @return void */ public function updateImageAction(ImageDto $imageDto, $profileNodeIdentifier) { /** @var Person $profile */ $profile = $this->profileService->getCurrentPartyProfile(); if ($profile->getIdentifier() !== $profileNodeIdentifier) { throw new UpdateNodeException('You can only update your own node', 1872398762); } if ($imageDto->getImage() instanceof Image) { $this->profileService->setImageToNode($profile, $imageDto->getImage(), $profile->getDisplayName(), [$profile->getDisplayName(), 'Profile images'], 'image', TRUE); $this->persistenceManager->persistAll(); $this->redirect('show', 'Frontend\\Node', 'TYPO3.Neos', ['node' => $profile]); } }
/** * Allow access to content if it is my content or when i have the allowed role * * @param string $contentUserIdentifier * @param array $allowedRoles * @param array $disallowedRoles * @return string */ public function render($contentUserIdentifier, $allowedRoles = [], $disallowedRoles = []) { try { $profile = $this->profileService->getCurrentPartyProfile(); } catch (\Exception $exception) { return; } $myRoles = $this->securityContext->getRoles(); $accessBasedOnRole = FALSE; foreach (array_unique($allowedRoles) as $role) { if (in_array($role, $myRoles)) { $accessBasedOnRole = TRUE; } } foreach (array_unique($disallowedRoles) as $role) { if (in_array($role, $myRoles)) { $accessBasedOnRole = FALSE; } } if ($profile->getIdentifier() === $contentUserIdentifier || $accessBasedOnRole === TRUE) { return $this->renderThenChild(); } return $this->renderElseChild(); }