/**
  * @return void
  * @throws \TYPO3\Flow\Security\Exception\AuthenticationRequiredException
  */
 public function initializeAction()
 {
     $this->authenticationManager->authenticate();
     if ($this->session->getLocation() == null && $this->request->getControllerName() != 'Login' && !$this->authenticationManager->getSecurityContext()->hasRole('DLigo.Animaltool:Admin') && $this->request->getControllerActionName() != 'select' && $this->request->getControllerName() != 'Location') {
         $this->redirect('select', 'location');
     }
     if ($this->request->hasArgument('cancel')) {
         if (!($this->request->getControllerActionName() == 'merge' && $this->request->getControllerName() == 'Animal')) {
             $this->redirect('index', 'animal');
         }
     }
     $msgs = $this->flashMessageContainer->getMessagesAndFlush();
     foreach ($msgs as $msg) {
         if ($msg->getSeverity() == 'Error' && $msg->getTitle() == '' && $msg->getCode() === null) {
             continue;
         }
         $this->flashMessageContainer->addMessage($msg);
     }
     if (isset($this->arguments['animal'])) {
         $this->arguments['animal']->getPropertyMappingConfiguration()->forProperty('birthday')->setTypeConverterOption('TYPO3\\Flow\\Property\\TypeConverter\\DateTimeConverter', \TYPO3\Flow\Property\TypeConverter\DateTimeConverter::CONFIGURATION_DATE_FORMAT, 'Y-m-d');
     }
     if (isset($this->arguments['newAnimal'])) {
         $this->arguments['newAnimal']->getPropertyMappingConfiguration()->forProperty('birthday')->setTypeConverterOption('TYPO3\\Flow\\Property\\TypeConverter\\DateTimeConverter', \TYPO3\Flow\Property\TypeConverter\DateTimeConverter::CONFIGURATION_DATE_FORMAT, 'Y-m-d');
     }
 }
 /**
  * @param integer $step
  * @return void
  * @Flow\SkipCsrfProtection
  */
 public function indexAction($step = 0)
 {
     $this->currentStepIndex = $step;
     $this->checkRequestedStepIndex();
     $currentStep = $this->instantiateCurrentStep();
     $controller = $this;
     $callback = function (\TYPO3\Form\Core\Model\FinisherContext $finisherContext) use($controller, $currentStep) {
         $controller->postProcessStep($finisherContext->getFormValues(), $currentStep);
     };
     $formDefinition = $currentStep->getFormDefinition($callback);
     if ($this->currentStepIndex > 0) {
         $formDefinition->setRenderingOption('previousStepUri', $this->uriBuilder->uriFor('index', array('step' => $this->currentStepIndex - 1)));
     }
     if ($currentStep->isOptional()) {
         $formDefinition->setRenderingOption('nextStepUri', $this->uriBuilder->uriFor('index', array('step' => $this->currentStepIndex + 1)));
     }
     $totalAmountOfSteps = count($this->settings['steps']);
     if ($this->currentStepIndex === $totalAmountOfSteps - 1) {
         $formDefinition->setRenderingOption('finalStep', TRUE);
         $this->authenticationManager->logout();
     }
     $response = new \TYPO3\Flow\Http\Response($this->response);
     $form = $formDefinition->bind($this->request, $response);
     try {
         $renderedForm = $form->render();
     } catch (\TYPO3\Setup\Exception $exception) {
         $this->addFlashMessage($exception->getMessage(), 'Exception while executing setup step', \TYPO3\Flow\Error\Message::SEVERITY_ERROR);
         $this->redirect('index', NULL, NULL, array('step' => $this->currentStepIndex));
     }
     $this->view->assignMultiple(array('form' => $renderedForm, 'totalAmountOfSteps' => $totalAmountOfSteps, 'currentStepNumber' => $this->currentStepIndex + 1));
 }
 /**
  *
  * @return void
  */
 public function logoutAction()
 {
     $this->authenticationManager->logout();
     $this->session->clear();
     $this->addFlashMessage('Successfully logged out.', '', \TYPO3\Flow\Error\Message::SEVERITY_OK, array(), 'flash.logout');
     $this->redirect('index', 'Login');
 }
 /**
  * Sets up this test case
  */
 public function setUp()
 {
     $this->securityContext = $this->getAccessibleMock(\TYPO3\Flow\Security\Context::class, array('separateActiveAndInactiveTokens'));
     $this->mockAuthenticationManager = $this->getMock(\TYPO3\Flow\Security\Authentication\AuthenticationManagerInterface::class);
     $this->mockAuthenticationManager->expects($this->any())->method('getTokens')->will($this->returnValue(array()));
     $this->securityContext->injectAuthenticationManager($this->mockAuthenticationManager);
     $this->mockActionRequest = $this->getMockBuilder(\TYPO3\Flow\Mvc\ActionRequest::class)->disableOriginalConstructor()->getMock();
     $this->securityContext->setRequest($this->mockActionRequest);
 }
 /**
  * @return void
  */
 public function logoutAction()
 {
     try {
         $this->authenticationManager->logout();
         $this->redirectToUri('/');
         return;
     } catch (\Exception $e) {
         return $e->getMessage();
     }
 }
 /**
  * Index action
  *
  * @param string $username
  * @return void
  */
 public function indexAction($username = NULL)
 {
     if ($this->authenticationManager->isAuthenticated()) {
         if (isset($this->settings['Redirect']['signedIn'])) {
             $redirect = $this->settings['Redirect']['signedIn'];
             $this->redirect($redirect['actionName'], $redirect['controllerName'], $redirect['packageKey']);
         }
         $this->redirect('signedIn');
     }
     $this->view->assign('username', $username);
     $this->view->assign('hostname', $this->request->getHttpRequest()->getBaseUri()->getHost());
     $this->view->assign('date', new \DateTime());
 }
 /**
  * Adds a NotEmptyValidator to the current element if the "trigger" value is not empty.
  * The trigger can be configured with $this->properties['triggerPropertyPath']
  *
  * @param \TYPO3\Form\Core\Runtime\FormRuntime $formRuntime
  * @return void
  */
 protected function requireIfTriggerIsSet(\TYPO3\Form\Core\Runtime\FormRuntime $formRuntime)
 {
     if ($formRuntime->getRequest()->getParentRequest()->getControllerActionName() == 'newDataSheet') {
         if ($this->authenticationManager->isAuthenticated() && $this->authenticationManager->getSecurityContext()->hasRole('GIB.GradingTool:Administrator')) {
             $this->addValidator(new \TYPO3\Flow\Validation\Validator\NotEmptyValidator());
         } elseif (!$this->authenticationManager->isAuthenticated()) {
             $this->addValidator(new \TYPO3\Flow\Validation\Validator\NotEmptyValidator());
         } else {
             return;
         }
     } elseif ($formRuntime->getRequest()->getParentRequest()->getControllerActionName() == 'editDataSheet') {
         return;
     }
 }
Exemple #8
0
 /**
  * @return \DLigo\Animaltool\Domain\Model\User
  */
 public function getUser()
 {
     if (!$this->user) {
         $this->user = $this->authenticationManager->getSecurityContext()->getAccount()->getParty();
     }
     return $this->user;
 }
Exemple #9
0
 /**
  * @param string $username
  */
 public function setUsername($username = NULL)
 {
     $this->username = $username;
     $securityContext = $this->authenticationManager->getSecurityContext();
     if ($securityContext->isInitialized() && $securityContext->getAccount()) {
         $this->username = $this->authenticationManager->getSecurityContext()->getAccount()->getAccountIdentifier();
     }
 }
 /**
  * Invokes the security interception
  *
  * @return boolean TRUE if the security checks was passed
  * @throws \TYPO3\Flow\Security\Exception\AccessDeniedException
  * @throws \TYPO3\Flow\Security\Exception\AuthenticationRequiredException if an entity could not be found (assuming it is bound to the current session), causing a redirect to the authentication entrypoint
  * @throws \TYPO3\Flow\Security\Exception\NoTokensAuthenticatedException if no tokens could be found and the accessDecisionManager denied access to the resource, causing a redirect to the authentication entrypoint
  */
 public function invoke()
 {
     try {
         $this->authenticationManager->authenticate();
     } catch (\Doctrine\ORM\EntityNotFoundException $exception) {
         throw new \TYPO3\Flow\Security\Exception\AuthenticationRequiredException('Could not authenticate. Looks like a broken session.', 1358971444, $exception);
     } catch (\TYPO3\Flow\Security\Exception\NoTokensAuthenticatedException $noTokensAuthenticatedException) {
         // We still need to check if the resource is available to "Everybody".
         try {
             $this->accessDecisionManager->decideOnJoinPoint($this->joinPoint);
             return;
         } catch (\TYPO3\Flow\Security\Exception\AccessDeniedException $accessDeniedException) {
             throw $noTokensAuthenticatedException;
         }
     }
     $this->accessDecisionManager->decideOnJoinPoint($this->joinPoint);
 }
 /**
  * Matches a \TYPO3\Flow\Mvc\RequestInterface against the configured CSRF pattern rules and
  * searches for invalid csrf tokens. If this returns TRUE, the request is invalid!
  *
  * @param RequestInterface $request The request that should be matched
  * @return boolean TRUE if the pattern matched, FALSE otherwise
  * @throws AuthenticationRequiredException
  */
 public function matchRequest(RequestInterface $request)
 {
     if (!$request instanceof ActionRequest || $request->getHttpRequest()->isMethodSafe()) {
         $this->systemLogger->log('CSRF: No token required, safe request', LOG_DEBUG);
         return false;
     }
     if ($this->authenticationManager->isAuthenticated() === false) {
         $this->systemLogger->log('CSRF: No token required, not authenticated', LOG_DEBUG);
         return false;
     }
     if ($this->securityContext->areAuthorizationChecksDisabled() === true) {
         $this->systemLogger->log('CSRF: No token required, authorization checks are disabled', LOG_DEBUG);
         return false;
     }
     $controllerClassName = $this->objectManager->getClassNameByObjectName($request->getControllerObjectName());
     $actionMethodName = $request->getControllerActionName() . 'Action';
     if (!$this->hasPolicyEntryForMethod($controllerClassName, $actionMethodName)) {
         $this->systemLogger->log(sprintf('CSRF: No token required, method %s::%s() is not restricted by a policy.', $controllerClassName, $actionMethodName), LOG_DEBUG);
         return false;
     }
     if ($this->reflectionService->isMethodTaggedWith($controllerClassName, $actionMethodName, 'skipcsrfprotection')) {
         $this->systemLogger->log(sprintf('CSRF: No token required, method %s::%s() is tagged with a "skipcsrfprotection" annotation', $controllerClassName, $actionMethodName), LOG_DEBUG);
         return false;
     }
     $httpRequest = $request->getHttpRequest();
     if ($httpRequest->hasHeader('X-Flow-Csrftoken')) {
         $csrfToken = $httpRequest->getHeader('X-Flow-Csrftoken');
     } else {
         $internalArguments = $request->getMainRequest()->getInternalArguments();
         $csrfToken = isset($internalArguments['__csrfToken']) ? $internalArguments['__csrfToken'] : null;
     }
     if (empty($csrfToken)) {
         $this->systemLogger->log(sprintf('CSRF: token was empty but a valid token is required for %s::%s()', $controllerClassName, $actionMethodName), LOG_DEBUG);
         return true;
     }
     if (!$this->securityContext->hasCsrfProtectionTokens()) {
         throw new AuthenticationRequiredException(sprintf('CSRF: No CSRF tokens in security context, possible session timeout. A valid token is required for %s::%s()', $controllerClassName, $actionMethodName), 1317309673);
     }
     if ($this->securityContext->isCsrfProtectionTokenValid($csrfToken) === false) {
         $this->systemLogger->log(sprintf('CSRF: token was invalid but a valid token is required for %s::%s()', $controllerClassName, $actionMethodName), LOG_DEBUG);
         return true;
     }
     $this->systemLogger->log(sprintf('CSRF: Successfully verified token for %s::%s()', $controllerClassName, $actionMethodName), LOG_DEBUG);
     return false;
 }
 /**
  * Invokes the security interception
  *
  * @return boolean TRUE if the security checks was passed
  * @throws AccessDeniedException
  * @throws AuthenticationRequiredException if an entity could not be found (assuming it is bound to the current session), causing a redirect to the authentication entrypoint
  * @throws NoTokensAuthenticatedException if no tokens could be found and the accessDecisionManager denied access to the privilege target, causing a redirect to the authentication entrypoint
  */
 public function invoke()
 {
     $reason = '';
     $privilegeSubject = new MethodPrivilegeSubject($this->joinPoint);
     try {
         $this->authenticationManager->authenticate();
     } catch (EntityNotFoundException $exception) {
         throw new AuthenticationRequiredException('Could not authenticate. Looks like a broken session.', 1358971444, $exception);
     } catch (NoTokensAuthenticatedException $noTokensAuthenticatedException) {
         // We still need to check if the privilege is available to "TYPO3.Flow:Everybody".
         if ($this->privilegeManager->isGranted(\TYPO3\Flow\Security\Authorization\Privilege\Method\MethodPrivilegeInterface::class, $privilegeSubject, $reason) === false) {
             throw new NoTokensAuthenticatedException($noTokensAuthenticatedException->getMessage() . chr(10) . $reason, $noTokensAuthenticatedException->getCode());
         }
     }
     if ($this->privilegeManager->isGranted(\TYPO3\Flow\Security\Authorization\Privilege\Method\MethodPrivilegeInterface::class, $privilegeSubject, $reason) === false) {
         throw new AccessDeniedException($this->renderDecisionReasonMessage($reason), 1222268609);
     }
 }
 /**
  * Prepares the environment for and conducts an account authentication
  *
  * @param Account $account
  * @return void
  */
 protected function authenticateAccount(Account $account)
 {
     $this->testingProvider->setAuthenticationStatus(TokenInterface::AUTHENTICATION_SUCCESSFUL);
     $this->testingProvider->setAccount($account);
     $this->securityContext->clearContext();
     /** @var RequestHandler $requestHandler */
     $this->securityContext->setRequest($this->mockActionRequest);
     $this->authenticationManager->authenticate();
 }
 /**
  * Matches a \TYPO3\Flow\Mvc\RequestInterface against the configured CSRF pattern rules and
  * searches for invalid csrf tokens. If this returns TRUE, the request is invalid!
  *
  * @param \TYPO3\Flow\Mvc\RequestInterface $request The request that should be matched
  * @return boolean TRUE if the pattern matched, FALSE otherwise
  * @throws \TYPO3\Flow\Security\Exception\AuthenticationRequiredException
  */
 public function matchRequest(\TYPO3\Flow\Mvc\RequestInterface $request)
 {
     if (!$request instanceof ActionRequest || $request->getHttpRequest()->isMethodSafe()) {
         $this->systemLogger->log('No CSRF required, safe request', LOG_DEBUG);
         return FALSE;
     }
     if ($this->authenticationManager->isAuthenticated() === FALSE) {
         $this->systemLogger->log('No CSRF required, not authenticated', LOG_DEBUG);
         return FALSE;
     }
     if ($this->securityContext->areAuthorizationChecksDisabled() === TRUE) {
         $this->systemLogger->log('No CSRF required, authorization checks are disabled', LOG_DEBUG);
         return FALSE;
     }
     $controllerClassName = $this->objectManager->getClassNameByObjectName($request->getControllerObjectName());
     $actionName = $request->getControllerActionName() . 'Action';
     if (!$this->policyService->hasPolicyEntryForMethod($controllerClassName, $actionName)) {
         $this->systemLogger->log(sprintf('CSRF protection filter: allowed %s request without requiring CSRF token because action "%s" in controller "%s" is not restricted by a policy.', $request->getHttpRequest()->getMethod(), $actionName, $controllerClassName), LOG_NOTICE);
         return FALSE;
     }
     if ($this->reflectionService->isMethodTaggedWith($controllerClassName, $actionName, 'skipcsrfprotection')) {
         return FALSE;
     }
     $httpRequest = $request->getHttpRequest();
     if ($httpRequest->hasHeader('X-Flow-Csrftoken')) {
         $csrfToken = $httpRequest->getHeader('X-Flow-Csrftoken');
     } else {
         $internalArguments = $request->getMainRequest()->getInternalArguments();
         $csrfToken = isset($internalArguments['__csrfToken']) ? $internalArguments['__csrfToken'] : NULL;
     }
     if (empty($csrfToken)) {
         $this->systemLogger->log('CSRF token was empty', LOG_DEBUG);
         return TRUE;
     }
     if (!$this->securityContext->hasCsrfProtectionTokens()) {
         throw new \TYPO3\Flow\Security\Exception\AuthenticationRequiredException('No tokens in security context, possible session timeout', 1317309673);
     }
     if ($this->securityContext->isCsrfProtectionTokenValid($csrfToken) === FALSE) {
         $this->systemLogger->log('CSRF token was invalid', LOG_DEBUG);
         return TRUE;
     }
     // the CSRF token was necessary and is valid
     return FALSE;
 }
 /**
  * Prepares the environment for and conducts an account authentication
  *
  * @param \TYPO3\Flow\Security\Account $account
  * @return void
  * @api
  */
 protected function authenticateAccount(\TYPO3\Flow\Security\Account $account)
 {
     $this->testingProvider->setAuthenticationStatus(\TYPO3\Flow\Security\Authentication\TokenInterface::AUTHENTICATION_SUCCESSFUL);
     $this->testingProvider->setAccount($account);
     $this->securityContext->clearContext();
     $requestHandler = self::$bootstrap->getActiveRequestHandler();
     $actionRequest = $this->route($requestHandler->getHttpRequest());
     $this->securityContext->setRequest($actionRequest);
     $this->authenticationManager->authenticate();
 }
 /**
  * @test
  */
 public function csrfTokenFieldIsRenderedForUnsafeRequests()
 {
     /** @var FormViewHelper|\PHPUnit_Framework_MockObject_MockObject $viewHelper */
     $viewHelper = $this->getAccessibleMock(\TYPO3\Fluid\ViewHelpers\FormViewHelper::class, null, array(), '', false);
     $this->injectDependenciesIntoViewHelper($viewHelper);
     $this->securityContext->expects($this->any())->method('isInitialized')->will($this->returnValue(true));
     $this->mockAuthenticationManager->expects($this->any())->method('isAuthenticated')->will($this->returnValue(true));
     $this->securityContext->expects($this->atLeastOnce())->method('getCsrfProtectionToken')->will($this->returnValue('CSRFTOKEN'));
     $this->assertEquals('<input type="hidden" name="__csrfToken" value="CSRFTOKEN" />' . chr(10), $viewHelper->_call('renderCsrfTokenField'));
 }
 /**
  * Render the a hidden field with a CSRF token
  *
  * @return string the CSRF token field
  */
 protected function renderCsrfTokenField()
 {
     if (strtolower($this->arguments['method']) === 'get') {
         return '';
     }
     if (!$this->securityContext->isInitialized() || !$this->authenticationManager->isAuthenticated()) {
         return '';
     }
     $csrfToken = $this->securityContext->getCsrfProtectionToken();
     return '<input type="hidden" name="__csrfToken" value="' . htmlspecialchars($csrfToken) . '" />' . chr(10);
 }
 /**
  * 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();
 }
 /**
  * Receive an SSO authentication callback and trigger authentication
  * through the SingleSignOnProvider.
  *
  * GET /sso/authentication/callback?...
  *
  * @param string $callbackUri
  * @return void
  */
 public function callbackAction($callbackUri)
 {
     try {
         $this->authenticationManager->authenticate();
     } catch (\TYPO3\Flow\Security\Exception\AuthenticationRequiredException $exception) {
         $authenticationException = $exception;
     }
     if ($this->authenticationManager->isAuthenticated()) {
         $storedRequest = $this->securityContext->getInterceptedRequest();
         if ($storedRequest !== NULL) {
             $this->securityContext->setInterceptedRequest(NULL);
             $this->redirectToRequest($storedRequest);
         } else {
             // TODO Do we have to check the URI?
             $this->redirectToUri($callbackUri);
         }
     } else {
         throw new \Flowpack\SingleSignOn\Client\Exception('Could not authenticate in callbackAction triggered by the SSO server.', 1366613161, isset($authenticationException) ? $authenticationException : NULL);
     }
 }
 /**
  * Initializes all actions with commons logic.
  */
 protected function initializeAction()
 {
     // Alternative to Flow's own json handling
     // FIXME
     if ($this->request->hasArgument('json')) {
         $this->isJson = true;
         $this->request->setFormat('json');
         $this->view = new \TYPO3\Flow\Mvc\View\JsonView();
         $this->view->setControllerContext($this->controllerContext);
     }
     if ($this->securityContext != null) {
         $account = $this->securityContext->getAccount();
         if ($account == null) {
             if ($this->isJson) {
                 $this->throwStatus(403);
             } else {
                 $this->authenticationManager->authenticate();
             }
         } else {
             /** @var \_OurBrand_\My\Domain\Model\User $user */
             $user = $account->getParty();
             if (!$user) {
                 // Seriously bad!
                 $this->throwStatus(403);
             }
             // Necessary for our easy role identifier functions!
             if ($user->getAccounts()->count() == 0) {
                 $user->addAccount($account);
             }
             $this->currentUser = $user;
             // Set the quiz subjects that this user has access to.
             if (count($user->getQuizSubscriptionDataForQuizType(0)) == 0) {
                 $this->accessHelper->setUserSubjectsAndTeamLevels($user);
             }
         }
     } else {
         if ($this->isJson) {
             $this->throwStatus(403);
         } else {
             $this->authenticationManager->authenticate();
         }
     }
     if ($this->loginSession->getData('studentQuizSession') != null) {
         $this->studentQuizSession = $this->loginSession->getData('studentQuizSession');
     }
     // Prevent browser caching of content. Everything is dynamic in this application.
     $this->response->setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
     $this->response->setHeader('Pragma', 'no-cache');
     $this->response->setHeader('Expires', '0');
 }
Exemple #21
0
 /**
  * Logout all active authentication tokens.
  *
  * @return void
  */
 public function logoutAction()
 {
     $this->authenticationManager->logout();
     $this->addFlashMessage('Successfully logged out.', 'Logged out');
     $this->redirect('login');
 }
 public function logoutAction()
 {
     $this->authenticationManager->logout();
     $this->flashMessageContainer->addMessage(new \TYPO3\Flow\Error\Error('Erfolgreich abgemeldet.'));
     $this->redirect('index', 'Dashboard');
 }
 /**
  * Logs all active tokens out. Override this, if you want to
  * have some custom action here. You can always call the parent
  * method to do the actual logout.
  *
  * @return void
  */
 public function logoutAction()
 {
     $this->authenticationManager->logout();
 }
 /**
  * Invokes the the authentication, if needed.
  *
  * @return boolean TRUE if the security checks was passed
  */
 public function invoke()
 {
     $this->authenticationManager->authenticate();
 }
 /**
  * Sets a new password for the given user
  *
  * This method will iterate over all accounts owned by the given user and, if the account uses a UsernamePasswordToken,
  * sets a new password accordingly.
  *
  * @param User $user The user to set the password for
  * @param string $password A new password
  * @return void
  * @api
  */
 public function setUserPassword(User $user, $password)
 {
     $tokens = $this->authenticationManager->getTokens();
     $indexedTokens = array();
     foreach ($tokens as $token) {
         /** @var TokenInterface $token */
         $indexedTokens[$token->getAuthenticationProviderName()] = $token;
     }
     foreach ($user->getAccounts() as $account) {
         /** @var Account $account */
         $authenticationProviderName = $account->getAuthenticationProviderName();
         if (isset($indexedTokens[$authenticationProviderName]) && $indexedTokens[$authenticationProviderName] instanceof UsernamePassword) {
             $account->setCredentialsSource($this->hashService->hashPassword($password));
             $this->accountRepository->update($account);
         }
     }
 }
 public function addAction()
 {
     $currentUser = $this->authenticationManager->getSecurityContext()->getAccount()->getParty();
     $photoInfo = $this->request->getArgument("photo");
     $actionData = $this->request->getArgument("action");
     $actionData = json_decode($actionData, true);
     $animalData = $this->request->getArgument("animal");
     $animalData = json_decode($animalData, true);
     $ownerData = $this->request->getArgument("owner");
     $ownerData = json_decode($ownerData, true);
     $photoData = $this->request->getArgument("photo");
     $action = $this->propertyMapper->convert($actionData, 'DLigo\\Animaltool\\Domain\\Model\\Action');
     $action->setDate(new \DateTime('now'));
     $user = $this->propertyMapper->convert($actionData['team'], 'DLigo\\Animaltool\\Domain\\Model\\User');
     $lastId = $user->getLastBoxID();
     $action->setTeam($user);
     $box = explode('-', $actionData['boxID']);
     if ($lastId > $box[1]) {
         $action->setBoxID($user->getTeamID() . '-' . ($lastId + 1));
     }
     $animal = $this->propertyMapper->convert($animalData, 'DLigo\\Animaltool\\Domain\\Model\\Animal');
     $birthday = \DateTime::createFromFormat("U", $animalData["birthday"]);
     if (!empty($animalData["birthday"])) {
         $birthday = \DateTime::createFromFormat("U", $animalData["birthday"]);
         $birthday->setTime(0, 0, 0);
         $animal->setBirthday($birthday);
     }
     $action->setAnimal($animal);
     $owner = null;
     if (isset($animalData["isPrivate"]) && $animalData["isPrivate"]) {
         $owner = $this->propertyMapper->convert($ownerData, 'DLigo\\Animaltool\\Domain\\Model\\Owner');
         $animal->setOwner($owner);
         $animal->setEarTag(null);
         if (!empty($animalData["earTag"])) {
             $rfid = $animalData["earTag"];
             $oldAnimal = $this->animalRepository->findOneByRFID($rfid);
             if ($oldAnimal == null) {
                 $animal->setRFID($rfid);
             }
         }
     } else {
         if (!empty($animalData["earTag"])) {
             $eartag = $animalData["earTag"];
             $oldAnimal = $this->animalRepository->findOneByEarTag($eartag);
             if ($oldAnimal != null) {
                 $animal->setEarTag(null);
             }
         }
     }
     $photo = $this->resourceManager->importUploadedResource($photoInfo);
     //$this->systemLogger->log(\TYPO3\Flow\var_dump($photo,"Photo",true,true),LOG_INFO);
     $animal->setPhoto($photo);
     if ($owner) {
         $this->ownerRepository->add($owner);
     }
     $this->animalRepository->add($animal);
     $this->actionRepository->add($action);
     $this->userRepository->update($user);
     $this->persistenceManager->persistAll();
     $this->response->setStatus(201);
     echo "{" . '"lastID": ' . $currentUser->getLastBoxID() . "}";
     flush();
     ob_flush();
 }
 /**
  * Dashboard for project manager
  */
 public function dashboardAction()
 {
     /** @var \GIB\GradingTool\Domain\Model\ProjectManager $projectManager */
     $projectManager = $this->authenticationManager->getSecurityContext()->getParty();
     $this->view->assignMultiple(array('projects' => $projectManager->getProjects()));
 }
 public function logoutAction()
 {
     $this->authenticationManager->logout();
     $this->flashMessageContainer->addMessage(new \TYPO3\Flow\Error\Error('Successfully logged out.'));
     $this->redirect('index', 'Login');
 }
 /**
  * Returns TRUE, if at least one of the currently authenticated accounts holds
  * a role with the given identifier, also recursively.
  *
  * @param string $roleIdentifier The string representation of the role to search for
  * @return boolean TRUE, if a role with the given string representation was found
  */
 public function hasRole($roleIdentifier)
 {
     if ($roleIdentifier === 'TYPO3.Flow:Everybody') {
         return true;
     }
     if ($roleIdentifier === 'TYPO3.Flow:Anonymous') {
         return !$this->authenticationManager->isAuthenticated();
     }
     if ($roleIdentifier === 'TYPO3.Flow:AuthenticatedUser') {
         return $this->authenticationManager->isAuthenticated();
     }
     $roles = $this->getRoles();
     return isset($roles[$roleIdentifier]);
 }
Exemple #30
0
 /**
  * Logout the user and redirect back to the login form.
  *
  * @return void
  */
 public function logoutAction()
 {
     $this->authenticationManager->logout();
     $this->addFlashMessage($this->translate('status_logout_success', 'Login'));
     $this->redirect('index', 'Login');
 }