/**
  * @dataProvider providerTestFactory
  */
 public function testFactory($config)
 {
     $serviceManager = new ServiceManager();
     $serviceManager->setService('Config', $config);
     $factory = new ModuleOptionsFactory();
     $defaultOption = new ModuleOptions(array());
     $object = $factory->createService($serviceManager);
     $this->assertInstanceOf('ZfcUser\\Options\\ModuleOptions', $object);
     if (isset($config['zfcuser'])) {
         $this->assertNotEquals($defaultOption->getLoginRedirectRoute(), $object->getLoginRedirectRoute());
         $this->assertEquals($config['zfcuser']['loginRedirectRoute'], $object->getLoginRedirectRoute());
     } else {
         $this->assertEquals($defaultOption->getLoginRedirectRoute(), $object->getLoginRedirectRoute());
     }
 }
Ejemplo n.º 2
0
 /**
  * Returns the url to redirect to based on current route.
  * If $redirect is set and the option to use redirect is set to true, it
  * will return the $redirect url.
  *
  * @param string $currentRoute        	
  * @param bool $redirect        	
  * @return mixed
  */
 protected function getRedirect($currentRoute, $redirect = false)
 {
     $useRedirect = $this->options->getUseRedirectParameterIfPresent();
     $routeExists = $redirect && $this->routeExists($redirect);
     if (!$useRedirect || !$routeExists) {
         $redirect = false;
     }
     switch ($currentRoute) {
         case 'zfcuser/register':
         case 'zfcuser/login':
         case 'zfcuser/authenticate':
             if ($redirect && ($match = $this->routeExists($redirect)) == true) {
                 $route = $match->getMatchedRouteName();
                 return $this->router->assemble(array(), array('name' => $route));
             } else {
                 $route = $this->options->getLoginRedirectRoute();
                 return $this->router->assemble(array(), array('name' => $route));
             }
             break;
         case 'zfcuser/logout':
             $route = $redirect ?: $this->options->getLogoutRedirectRoute();
             return $this->router->assemble(array(), array('name' => $route));
             break;
         default:
             return $this->router->assemble(array(), array('name' => 'zfcuser'));
     }
 }
Ejemplo n.º 3
0
 /**
  * Returns the url to redirect to based on current route.
  * If $redirect is set and the option to use redirect is set to true, it will return the $redirect url.
  *
  * @param  string $currentRoute
  * @param  bool   $redirect
  * @return mixed
  */
 private function getRedirect($currentRoute, $redirect = false)
 {
     $useRedirect = $this->options->getUseRedirectParameterIfPresent();
     $routeExists = $redirect && $this->routeExists($redirect);
     if (!$useRedirect || !$routeExists) {
         $redirect = false;
     }
     switch ($currentRoute) {
         case 'zfcuser/login':
         case 'scn-social-auth-user/login':
         case 'scn-social-auth-user/register':
         case 'scn-social-auth-user/authenticate/provider':
         case 'scn-social-auth-user/add-provider/provider':
             $route = $redirect ?: $this->options->getLoginRedirectRoute();
             return $this->router->assemble(array(), array('name' => $route));
             break;
         case 'zfcuser/logout':
         case 'scn-social-auth-user/logout':
             $route = $redirect ?: $this->options->getLogoutRedirectRoute();
             return $this->router->assemble(array(), array('name' => $route));
             break;
         default:
             return $this->router->assemble(array(), array('name' => 'zfcuser'));
     }
 }
 /**
  * Returns the url to redirect to based on current url.
  * If $redirect is set and the option to use redirect is set to true, it will return the $redirect url
  * after verifying that the url is in the whitelist.
  *
  * @param string $currentRoute
  * @param bool $redirect
  * @return mixed
  */
 private function getRedirect($currentRoute, $redirect = false)
 {
     $useRedirect = $this->zfcUserOptions->getUseRedirectParameterIfPresent();
     $urlAllowed = $redirect && $this->urlWhitelisted($redirect);
     if ($useRedirect && $urlAllowed) {
         return $redirect;
     }
     switch ($currentRoute) {
         case 'zfcuser/register':
         case 'zfcuser/login':
             $route = $this->zfcUserOptions->getLoginRedirectRoute();
             return $this->router->assemble(array(), array('name' => $route));
             break;
         case 'zfcuser/logout':
             $route = $this->zfcUserOptions->getLogoutRedirectRoute();
             return $this->router->assemble(array(), array('name' => $route));
             break;
         default:
             return $this->router->assemble(array(), array('name' => 'zfcuser'));
     }
 }
Ejemplo n.º 5
0
 public function newConversationAction()
 {
     if (!$this->zfcUserAuthentication()->hasIdentity()) {
         return $this->redirect()->toRoute($this->zfcUserOptions->getLoginRedirectRoute());
     }
     $users = $this->pmService->getUsers();
     $form = $this->newConversationForm;
     $viewModel = new ViewModel(['users' => $users, 'form' => $form]);
     $viewModel->setTemplate('eye4web/zfc-user/pm/new-conversation.phtml');
     $redirectUrl = $this->url()->fromRoute('eye4web/zfc-user/pm/new-conversation');
     $prg = $this->prg($redirectUrl, true);
     if ($prg instanceof Response) {
         return $prg;
     } elseif ($prg === false) {
         return $viewModel;
     }
     $form->setData($prg);
     if (!$form->isValid()) {
         return $viewModel;
     }
     $user = $this->zfcUserAuthentication()->getIdentity();
     $this->pmService->newConversation($form->getData(), $user);
     return $this->redirect()->toRoute('eye4web/zfc-user/pm/list');
 }
Ejemplo n.º 6
0
 /**
  * @covers ZfcUser\Options\ModuleOptions::getLoginRedirectRoute
  */
 public function testGetLoginRedirectRoute()
 {
     $this->assertEquals('zfcuser', $this->options->getLoginRedirectRoute());
 }