public function onDispatch(MvcEvent $e)
 {
     $this->layout('layout/login_register');
     /** INSTANTIATE FLASH MESSENGER **/
     $this->flashMessenger = $this->flashMessenger();
     return parent::onDispatch($e);
 }
 /**
  * @dataProvider providerTrueOrFalse
  * @depend testActionControllHasIdentity
  */
 public function testLoginActionIsNotPost($redirect)
 {
     $plugin = $this->setUpZfcUserAuthenticationPlugin(array('hasIdentity' => false));
     $flashMessenger = $this->getMock('Zend\\Mvc\\Controller\\Plugin\\FlashMessenger');
     $flashMessenger->expects($this->once())->method('setNamespace')->with('zfcuser-login-form')->will($this->returnSelf());
     $this->pluginManagerPlugins['flashMessenger'] = $flashMessenger;
     $request = $this->getMock('Zend\\Http\\Request');
     $request->expects($this->once())->method('isPost')->will($this->returnValue(false));
     $form = $this->loginForm;
     $form->expects($this->never())->method('isValid');
     $this->options->expects($this->any())->method('getUseRedirectParameterIfPresent')->will($this->returnValue((bool) $redirect));
     if ($redirect) {
         $params = new Parameters();
         $params->set('redirect', 'http://localhost/');
         $request->expects($this->any())->method('getQuery')->will($this->returnValue($params));
     }
     $this->helperMakePropertyAccessable($this->controller, 'request', $request);
     $result = $this->controller->loginAction();
     $this->assertArrayHasKey('loginForm', $result);
     $this->assertArrayHasKey('redirect', $result);
     $this->assertArrayHasKey('enableRegistration', $result);
     $this->assertInstanceOf('ZfcUser\\Form\\Login', $result['loginForm']);
     $this->assertSame($form, $result['loginForm']);
     if ($redirect) {
         $this->assertEquals('http://localhost/', $result['redirect']);
     } else {
         $this->assertFalse($result['redirect']);
     }
     $this->assertEquals($this->options->getEnableRegistration(), $result['enableRegistration']);
 }
 /**
  * Logout and clear the identity of the current user, including identities associated with impersonating another
  * user.
  *
  * @see \ZfcUser\Controller\UserController::logoutAction()
  */
 public function logoutAction()
 {
     // If the current user is being impersonated, the logout action must also end impersonation by clearing the
     // 'real user' identity.
     $this->getUserService()->getStorageForImpersonator()->clear();
     // Perform the rest of the logout action using ZfcUser functionality.
     return parent::logoutAction();
 }
 public function onDispatch(MvcEvent $e)
 {
     //        $action = $this->params('action');
     //
     //        if (!$this->_hasIdentity() && ($action != 'login') && !in_array($action, $this->publicActions))
     //        {
     //            return $this->redirect()->toRoute(static::ROUTE_LOGIN);
     //        }
     $this->layout('layout/dashboard');
     /** INSTANTIATE FLASH MESSENGER **/
     $this->flashMessenger = $this->flashMessenger();
     return parent::onDispatch($e);
 }
 public function createService(ServiceLocatorInterface $sm)
 {
     $userService = $sm->get('zfcuser_user_service');
     $loginEvents = $sm->get('EventManager');
     $loginForm = $sm->get('ZfcUser\\Form\\Login');
     $loginForm->setEventManager($loginEvents);
     $registerForm = $sm->get('ZfcUser\\Form\\Register');
     $controller = new UserController();
     $controller->setUserService($userService);
     $controller->setLoginForm($loginForm);
     $controller->setRegisterForm($registerForm);
     $controller->setServiceLocator($sm);
     return $controller;
 }
 /**
  * @dataProvider providerTestSetterGetterServices
  * @depend testActionControllHasIdentity
  */
 public function testSetterGetterServices($methode, $useServiceLocator, $servicePrototype, $serviceName, $callback = null)
 {
     $controller = new Controller();
     $controller->setPluginManager($this->pluginManager);
     //         $controller = $this->controller;
     if (is_callable($callback)) {
         call_user_func($callback, $this, $controller);
     }
     if ($useServiceLocator) {
         $serviceLocator = $this->getMock('\\Zend\\ServiceManager\\ServiceLocatorInterface');
         $serviceLocator->expects($this->once())->method('get')->with($serviceName)->will($this->returnValue($servicePrototype));
         $controller->setServiceLocator($serviceLocator);
     } else {
         call_user_func(array($controller, 'set' . $methode), $servicePrototype);
     }
     $result = call_user_func(array($controller, 'get' . $methode));
     $this->assertInstanceOf(get_class($servicePrototype), $result);
     $this->assertSame($servicePrototype, $result);
     // we need two check for every case
     $result = call_user_func(array($controller, 'get' . $methode));
     $this->assertInstanceOf(get_class($servicePrototype), $result);
     $this->assertSame($servicePrototype, $result);
 }
Exemple #7
0
 public function __construct($redirectCallback)
 {
     parent::__construct($redirectCallback);
 }
 public function registerAction()
 {
     $res = parent::registerAction();
     //var_dump($res);
     $request = $this->getRequest();
     if ($res instanceof Response && !$this->zfcUserAuthentication()->hasIdentity() && !$request->isPost()) {
         return $this->redirect()->toRoute('zfcuser/register/registered');
         //return $this->forward()->dispatch(get_class(), array('action' => 'registered'));
     }
     return $res;
 }