/** * @param string $style * @param $degree * @return string */ public function getDegreeLabel($style = 'bujitsudo', $degree) { if ($style === 'bujitsudo') { return $this->profileService->getBuJitsuDoOptions()[$degree]; } return $this->profileService->getJiuJitsuOptions()[$degree]; }
/** * @param string $emailAddress * @param string $requirement * * @throws \Exception * * @return string */ public function resetPasswordAction($emailAddress, $requirement = '') { if ($requirement !== '') { throw new \Exception('Bot detection', 12393182738); } $locale = new Locale('nl'); $account = $this->accountRepository->findActiveByAccountIdentifierAndAuthenticationProviderName($emailAddress, 'DefaultProvider'); if ($account instanceof Account) { try { /** @var Person $profile */ $profile = $this->profileService->getProfileNodeOfAccount($account); $password = $this->randomPassword(); $hashedPassword = $this->hashService->hashPassword($password, 'default'); $this->mailerService->sendEmail(array('email' => $emailAddress, 'name' => $profile->getDisplayName()), 'Nieuw wachtwoord', 'Packages/Application/BuJitsuDo.Authentication/Resources/Private/Templates/Email/PasswordReset.html', array('password' => $password, 'profile' => $profile)); $account->setCredentialsSource($hashedPassword); $this->accountRepository->update($account); $this->persistenceManager->persistAll(); } catch (\Exception $exception) { return $exception->getMessage(); } } else { $this->response->setHeader('Notification', $this->translator->translateById('profile.reset.password.response.failure', [], NULL, $locale, 'Main', 'BuJitsuDo.Authentication')); $this->response->setHeader('NotificationType', 'alert'); return ''; } $this->response->setHeader('Notification', $this->translator->translateById('profile.reset.password.response.success', [], NULL, $locale, 'Main', 'BuJitsuDo.Authentication')); $this->response->setHeader('NotificationType', 'success'); return ''; }
/** * @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 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(); } }
/** * @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(); }
/** * 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(); }
/** * @param FluidView $view` */ protected function initializeView(FluidView $view) { $captcha = new Captcha(); $captcha->setPublicKey($this->captchaSettings['publicKey']); $view->assignMultiple(['captcha' => $captcha->displayHTML('clean'), 'jiuJitsuOptions' => $this->profileService->getJiuJitsuOptions(), 'buJitsuDoOptions' => $this->profileService->getBuJitsuDoOptions()]); }