コード例 #1
0
 public function logoutAction()
 {
     $session = new Container('User');
     $session->getManager()->destroy();
     $this->getAuthService()->clearIdentity();
     return $this->redirect()->toRoute('login');
 }
コード例 #2
0
ファイル: IndexControllerTest.php プロジェクト: zfury/cmf
 public function tearDown()
 {
     $this->sessionProgress->getManager()->getStorage()->clear('progress_tracker');
     $forms = new Container('forms');
     $forms->getManager()->getStorage()->clear('forms');
     parent::tearDown();
 }
コード例 #3
0
ファイル: BreadcrumbFactory.php プロジェクト: odegroot/ers
 public function reset()
 {
     $clearance = new Container('forrest');
     $clearance->getManager()->getStorage()->clear('forrest');
     $this->forrest = new Container('forrest');
     $this->forrest->trace = new \ArrayObject();
 }
コード例 #4
0
 public function logoutAction()
 {
     $this->getAuthService()->getStorage()->clear();
     $user_session = new Container('webshop');
     $user_session->getManager()->destroy();
     return $this->redirect()->toRoute('webshop/product');
 }
コード例 #5
0
 public function logoutAction()
 {
     $session = new Container('User');
     $session->getManager()->destroy();
     $this->getAuthService()->clearIdentity();
     return $this->redirect()->toUrl('/article_to_read/public');
 }
コード例 #6
0
 public function loginAction()
 {
     $sessao = new Container();
     $id = $this->params()->fromRoute("id") ? $this->params()->fromRoute("id") : null;
     $request = $this->getRequest();
     if (empty($sessao->usuario)) {
         if ($request->isPost()) {
             $senha = $request->getPost('senha');
             $usuario = $request->getPost('usuario');
             if (!empty($senha) && !empty($usuario)) {
                 $user = new Login();
                 $user = $this->getLoginTable()->getLogin($usuario, $senha);
                 if (!$user) {
                     $this->redirect()->toRoute('errologin');
                 } else {
                     $sessao->usuario = $usuario;
                     $sessao->registro = time();
                     $this->redirect()->toRoute('dashboard');
                 }
             }
         }
     } else {
         if (!isset($id)) {
             $this->redirect()->toRoute('dashboard');
         } else {
             $sessao->getManager()->getStorage()->clear();
             $this->redirect()->toRoute('login');
         }
     }
 }
コード例 #7
0
 public function indexAction()
 {
     $userSession = new Container('user');
     /*$userSession->user_id = false;
     		$userSession->user_group = false;*/
     $userSession->getManager()->destroy();
     return $this->redirect()->toRoute('home');
 }
コード例 #8
0
 public function logoutAction()
 {
     $authService = $this->getServiceLocator()->get('AuthService');
     $session = new Container('User');
     $session->getManager()->destroy();
     $authService->clearIdentity();
     return $this->redirect()->toUrl('/login');
 }
コード例 #9
0
 function logoutAction()
 {
     $adminState = new Container('Admin');
     if (!is_null($adminState->Email)) {
         $adminState->getManager()->getStorage()->clear('Admin');
     }
     $this->redirect()->toRoute('admin');
 }
コード例 #10
0
 /**
  * Start over with the upgrade process in case of an error.
  *
  * @return mixed
  */
 public function resetAction()
 {
     foreach (array_keys($this->cookie->getAllValues()) as $k) {
         unset($this->cookie->{$k});
     }
     $storage = $this->session->getManager()->getStorage();
     $storage[$this->session->getName()] = new ArrayObject([], ArrayObject::ARRAY_AS_PROPS);
     return $this->forwardTo('Upgrade', 'Home');
 }
コード例 #11
0
ファイル: Authenticate.php プロジェクト: zource/zource
 public function logoutAction()
 {
     // Clear the identity and we also regenerate a new session id in order to make sure that new logins always
     // have a unique session id.
     $this->authenticationService->clearIdentity();
     $this->authSession->getManager()->expireSessionCookie();
     $this->resetTwoFactorAuthentication();
     return $this->redirect()->toRoute('login');
 }
コード例 #12
0
ファイル: BreadcrumbService.php プロジェクト: odegroot/ers
 public function reset()
 {
     $clearance = new Container('forrest');
     $clearance->getManager()->getStorage()->clear('forrest');
     $this->forrest = new Container('forrest');
     $this->forrest->active = 'fallback';
     $id = $this->getId();
     $this->forrest->{$id} = new \ArrayObject();
 }
コード例 #13
0
 public function logoutAction()
 {
     $this->login->logout();
     $sesion = new Container('reminderSesion');
     $sesion->getManager()->getStorage()->clear('reminderSesion');
     //$this->logger->info("Usuario desconectado: " . $this->login->getIdentity());
     //$this->flashMessengerPlus()->addSuccess('Logout Correcto!', 'Logout Correcto', false, null);
     return $this->redirect()->toRoute('login', array('controller' => 'login', 'action' => 'index'));
 }
コード例 #14
0
 public function deleteSession($username, $session, $ip)
 {
     if ($session == NULL) {
         $this->tableGateway->delete(array('username' => $username));
     } else {
         $this->tableGateway->delete(array('username' => $username, 'session' => $session, 'ip' => $ip));
     }
     $user_session = new Container('user');
     $user_session->getManager()->getStorage()->clear('user');
 }
コード例 #15
0
ファイル: UserController.php プロジェクト: trongle/book_zend2
 public function checkOutAction()
 {
     if ($this->request->isPost()) {
         $this->_options['tableName'] = "shopOrderTable";
         $this->getTable()->saveItem($this->_mainParam['data']);
         $ssOrder = new Container(BOOKONLINE_KEY . "_order");
         $ssOrder->getManager()->getStorage()->clear(BOOKONLINE_KEY . "_order");
     }
     return $this->redirect()->toRoute("homeShop");
 }
コード例 #16
0
ファイル: Adapter.php プロジェクト: zf-hipsters/authorize
 /**
  * Called when user id logged out
  * @param  AuthEvent $e event passed
  */
 public function logout()
 {
     $session = new SessionContainer($this->getStorage()->getNameSpace());
     $session->getManager()->destroy();
     $this->getStorage()->forgetMe();
     $storage = $this->getStorage()->read();
     if (isset($storage['identity'])) {
         unset($storage['identity']);
     }
 }
コード例 #17
0
ファイル: Db.php プロジェクト: stormtrooper42/shineisp2
 public function authenticate(AuthEvent $e)
 {
     if ($this->isSatisfied()) {
         $storage = $this->getStorage()->read();
         $e->setIdentity($storage['identity'])->setCode(AuthenticationResult::SUCCESS)->setMessages(array('Authentication successful.'));
         return;
     }
     $identity = $e->getRequest()->getPost()->get('identity');
     $credential = $e->getRequest()->getPost()->get('credential');
     $credential = $this->preProcessCredential($credential);
     $userObject = NULL;
     // Cycle through the configured identity sources and test each
     $fields = $this->getOptions()->getAuthIdentityFields();
     while (!is_object($userObject) && count($fields) > 0) {
         $mode = array_shift($fields);
         switch ($mode) {
             case 'username':
                 $userObject = $this->getMapper()->findByUsername($identity);
                 break;
             case 'email':
                 $userObject = $this->getMapper()->findByEmail($identity);
                 break;
         }
     }
     if (!$userObject) {
         $e->setCode(AuthenticationResult::FAILURE_IDENTITY_NOT_FOUND)->setMessages(array('A record with the supplied identity could not be found.'));
         $this->setSatisfied(false);
         return false;
     }
     if ($this->getOptions()->getEnableUserState()) {
         // Don't allow user to login if state is not in allowed list
         if (!in_array($userObject->getState(), $this->getOptions()->getAllowedLoginStates())) {
             $e->setCode(AuthenticationResult::FAILURE_UNCATEGORIZED)->setMessages(array('A record with the supplied identity is not active.'));
             $this->setSatisfied(false);
             return false;
         }
     }
     $password_posted = md5($credential);
     if ($password_posted != $userObject->getPassword()) {
         // Password does not match
         $e->setCode(AuthenticationResult::FAILURE_CREDENTIAL_INVALID)->setMessages(array('Supplied credential is invalid.'));
         $this->setSatisfied(false);
         return false;
     }
     // regen the id
     $session = new SessionContainer($this->getStorage()->getNameSpace());
     $session->getManager()->regenerateId();
     // Success!
     $e->setIdentity($userObject->getId());
     $this->setSatisfied(true);
     $storage = $this->getStorage()->read();
     $storage['identity'] = $e->getIdentity();
     $this->getStorage()->write($storage);
     $e->setCode(AuthenticationResult::SUCCESS)->setMessages(array('Authentication successful.'));
 }
コード例 #18
0
ファイル: RecordController.php プロジェクト: CUSAT/vufind
 /**
  * Save action - Allows the save template to appear,
  *   passes containingLists & nonContainingLists
  *
  * @return mixed
  */
 public function saveAction()
 {
     // Process form submission:
     if ($this->params()->fromPost('submit')) {
         return $this->processSave();
     }
     // Retrieve user object and force login if necessary:
     if (!($user = $this->getUser())) {
         return $this->forceLogin();
     }
     // If we got so far, we should save the referer for later use by the
     // ProcessSave action (to get back to where we came from after saving).
     // We shouldn't save follow-up information if it points to the Save
     // screen or the "create list" screen, as this causes confusing workflows;
     // in these cases, we will simply default to pushing the user to record view.
     $shibFollowup = new SessionContainer('ShibbolethSaveFollowup');
     $tURL = $shibFollowup->url;
     //only for Shibboleth case otherwise use the ordinary HTTP_Referer
     //(standard VuFind)
     if (!empty($tURL)) {
         $referer = $tURL;
         //clear the temporary session because we don't need it anymore
         //(the user was successfully authenticated)
         $shibFollowup->getManager()->getStorage()->clear('ShibbolethSaveFollowup');
     } else {
         $referer = $this->getRequest()->getServer()->get('HTTP_REFERER');
     }
     $followup = new SessionContainer($this->searchClassId . 'SaveFollowup');
     if (substr($referer, -5) != '/Save' && stripos($referer, 'MyResearch/EditList/NEW') === false) {
         $followup->url = $referer;
     }
     // Retrieve the record driver:
     $driver = $this->loadRecord();
     // Find out if the item is already part of any lists; save list info/IDs
     $listIds = array();
     $resources = $user->getSavedData($driver->getUniqueId(), null, $driver->getResourceSource());
     foreach ($resources as $userResource) {
         $listIds[] = $userResource->list_id;
     }
     // Loop through all user lists and sort out containing/non-containing lists
     $containingLists = $nonContainingLists = array();
     foreach ($user->getLists() as $list) {
         // Assign list to appropriate array based on whether or not we found
         // it earlier in the list of lists containing the selected record.
         if (in_array($list->id, $listIds)) {
             $containingLists[] = array('id' => $list->id, 'title' => $list->title);
         } else {
             $nonContainingLists[] = array('id' => $list->id, 'title' => $list->title);
         }
     }
     $view = $this->createViewModel(array('containingLists' => $containingLists, 'nonContainingLists' => $nonContainingLists));
     $view->setTemplate('record/save');
     return $view;
 }
コード例 #19
0
 /**
  *  Este metodo garante que um usuario não conseguira executar ação nenhuma quando
  * nao tem acesso para tal.
  */
 public function accessDeniedAction()
 {
     // Chegando aqui provavelmente terá algum erro na sessao para ser mostrado.
     $session = new Session(self::ACCESS_CONTROL_NAMESPACE);
     if (isset($session->view['errors']) && $session->view['errors']) {
         $this->view['errors'] = $session->view['errors'];
         $this->view['validation'] = $session->view['validation'];
     }
     $session->getManager()->getStorage()->clear(self::ACCESS_CONTROL_NAMESPACE);
     return $this->getView(false);
 }
コード例 #20
0
ファイル: FrontEndAuth.php プロジェクト: riteshkmr33/ovessnce
 public function logout()
 {
     $session = new Container('frontend');
     $session->getManager()->getStorage()->clear();
     $fb_login = new Container('facebook');
     $fb_login->getManager()->getStorage()->clear();
     $google_login = new Container('google');
     $google_login->getManager()->getStorage()->clear();
     $linkedin_login = new Container('linkedin');
     $linkedin_login->getManager()->getStorage()->clear();
 }
コード例 #21
0
ファイル: SessionController.php プロジェクト: trongle/zend-2
 public function index05Action()
 {
     $ssUser = new Container("user");
     $ssGroup = new Container("group");
     $ssUser->offsetSet("fullname", "trongle");
     $ssGroup->offsetSet("groupname", "sasfsaf");
     $ssUser->getManager()->getStorage()->clear("group");
     echo $ssUser->offsetGet("fullname");
     echo $ssGroup->offsetGet("groupname");
     return false;
 }
コード例 #22
0
ファイル: IndexController.php プロジェクト: sonny-one/zero
 public function dbparamAction()
 {
     $this->dbAdapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter');
     $usuario = new UsuarioTable($this->dbAdapter);
     $tsession = new SessionTable($this->dbAdapter);
     $id_db = $this->params()->fromRoute('id', 0);
     $sid = new Container('base');
     $dbParam = $sid->offsetGet('dbParam');
     for ($i = 0; $i < count($dbParam); $i++) {
         if ($id_db == $dbParam[$i]['id']) {
             $id_perfil = $dbParam[$i]['id_perfil'];
             $nro_session = $dbParam[$i]['nro_session'];
             $db_nombre = $dbParam[$i]['nombre_db'];
             $nombreComercial = $dbParam[$i]['nombre'];
             $perfil = $dbParam[$i]['perfil'];
             break;
         }
     }
     $id_usuario = $sid->offsetGet('id_usuario');
     $nroSessionDB = count($tsession->obtenetSesion($id_usuario, $id_db));
     if ($nro_session > 0 && $nroSessionDB >= $nro_session) {
         $sid->getManager()->getStorage()->clear();
         if (isset($_COOKIE['usuario'])) {
             unset($_COOKIE['usuario']);
         }
         if (isset($_COOKIE['password'])) {
             unset($_COOKIE['password']);
         }
         //return $this->forward()->dispatch('Application\Controller\Login',array('action'=>'index','id'=>4));
         return $this->redirect()->toUrl($this->getRequest()->getBaseUrl() . '/application/login/index/4');
     }
     $sid->offsetSet('dbNombre', $db_nombre);
     $sid->offsetSet('nombreComercial', $nombreComercial);
     $sid->offsetSet('id_db', $id_db);
     $sid->offsetSet('perfil', $perfil);
     $valores = array('id_usuario' => $id_usuario, 'id_db' => $id_db, 'ip_cliente' => $_SERVER['REMOTE_ADDR'], 'port_cliente' => $_SERVER['REMOTE_PORT']);
     $sid->offsetSet('idSession', $tsession->crearSesion($valores));
     //Mapeamos la base de datos
     $modulo = $usuario->getModulo($this->dbAdapter, $id_perfil);
     $sid->offsetSet('modulo', $modulo);
     if (count($modulo) > 1) {
         $urlHome = 'application';
     } else {
         $urlHome = $modulo[0]['url'];
     }
     $sid->offsetSet('urlHome', $urlHome);
     return $this->redirect()->toUrl($this->getRequest()->getBaseUrl() . '/' . $urlHome);
     //return new ViewModel();
 }
コード例 #23
0
ファイル: LoginTable.php プロジェクト: joonsantiago/nortes
 public function validarSessao()
 {
     $sessao = new Container();
     $seg = 1;
     if ($sessao->registro) {
         $seg = time() - $sessao->registro;
     }
     if (!empty($sessao->registro) && $seg < 300) {
         $sessao->registro = time();
         return false;
     } else {
         $sessao->getManager()->getStorage()->clear();
         return true;
     }
 }
コード例 #24
0
ファイル: IndexController.php プロジェクト: JeoffScott/dyplom
 public function changeLocaleEnglishAction()
 {
     // New Container will get he Language Session if the SessionManager already knows the language session.
     $session = new Container('language');
     //just clear the language session
     $session->getManager()->getStorage()->clear('language');
     $language = 'en_US';
     //set new language
     $request = $this->getRequest();
     $config = $this->serviceLocator->get('config');
     $session->language = $language;
     $translator = new \Zend\I18n\Translator\Translator();
     $translator->setLocale('en_US')->setFallbackLocale('en_US');
     return $this->redirect()->toRoute('home');
 }
コード例 #25
0
 public function indexAction()
 {
     $user_session = new Container('A_Login');
     $user_session->getManager()->getStorage()->clear();
     $submit = array();
     if ($this->getRequest()->getPost('submit')) {
         $username = $this->getRequest()->getPost('username');
         $password = $this->getRequest()->getPost('password');
         $row = $this->getAdminTable()->loginAdmin(array('username' => $username, 'password' => $password));
         if ($row and $row->id) {
             $user_session->username = $row->username;
             $user_session->email = $row->email;
             return $this->redirect()->toRoute('cpanel');
         } else {
             $submit = array('message' => 'Thông tin đăng nhập không chính xác');
         }
     }
     $viewModel = new ViewModel($submit);
     $viewModel->setTerminal(true);
     return $viewModel;
 }
コード例 #26
0
ファイル: Firephp.php プロジェクト: braghimsistemas/zf2lib
 /**
  * Joga dados do firephp salvo na sessao por redirecionamento.
  * 
  * @return mixed
  */
 public static function throwRedirectLog()
 {
     $session = new Container(__CLASS__);
     // Recupera dados
     $data = (array) $session->data;
     // Nomes possiveis dos tipos de mensagem
     // que o Zend usa como metodo.
     //
     // Para entender melhor faça.:
     // \Zend\Debug\Debug::dump(get_class_methods(self::getInstance()));
     // exit;
     $methodTypeName = array(Logger::ALERT => 'alert', Logger::CRIT => 'crit', Logger::DEBUG => 'debug', Logger::EMERG => 'emerg', Logger::ERR => 'err', Logger::INFO => 'info', Logger::NOTICE => 'notice', Logger::WARN => 'warn');
     // Joga dados no firephp
     foreach ($data as $type => $contents) {
         $method = $methodTypeName[$type];
         foreach ($contents as $value) {
             self::getInstance()->{$method}($value);
         }
     }
     // Apaga sessao
     $session->getManager()->getStorage()->clear(__CLASS__);
     return $data;
 }
コード例 #27
0
 /**
  * Formulário de pré-entrevista
  * 
  * Se a sessão de pré-entrevista não foi criada redireciona para o início da pré-entrevista (indexAction)
  * Salva o endereço se necessário, responsável se necessário, endereço do responsável se necessário e, é claro,
  * as informações da pré-entrevista.
  * 
  * @return ViewModel
  */
 public function studentPreInterviewFormAction()
 {
     $this->layout('application-clean/layout');
     $studentContainer = new Container('candidate');
     // id de inscrição não está na sessão redireciona para o início
     if (!$studentContainer->offsetExists('regId')) {
         return $this->redirect()->toRoute('recruitment/pre-interview', array('action' => 'index'));
     }
     $rid = $studentContainer->offsetGet('regId');
     try {
         $request = $this->getRequest();
         $em = $this->getEntityManager();
         $registration = $em->getReference('Recruitment\\Entity\\Registration', $rid);
         $person = $registration->getPerson();
         $options = array('person' => array('relative' => $person->isPersonUnderage(), 'address' => true, 'social_media' => false), 'pre_interview' => true);
         $form = new PreInterviewForm($em, $options);
         $form->bind($registration);
         if ($request->isPost()) {
             $form->setData($request->getPost());
             if ($form->isValid()) {
                 // gestão de duplicação de endereço e parentes
                 $this->adjustAddresses($person);
                 $this->adjustRelatives($person);
                 $this->updateRegistrationStatus($registration, RecruitmentStatus::STATUSTYPE_PREINTERVIEW_COMPLETE);
                 $em->persist($registration);
                 $em->flush();
                 $studentContainer->getManager()->getStorage()->clear('candidate');
                 return new ViewModel(array('registration' => null, 'form' => null, 'message' => 'Pré-entrevista concluída com com sucesso. ' . 'O formulário de pré-entrevista continuará disponível para futuras edições até a ' . 'conclusão de sua entrevista.'));
             } else {
                 return new ViewModel(array('registration' => $registration, 'form' => $form, 'message' => 'Existe(m) algum(ns) campo(s) não preenchido(s).'));
             }
         }
     } catch (Exception $ex) {
         return new ViewModel(array('registration' => null, 'form' => null, 'message' => 'Erro inesperado. Por favor, entre em contato com o administrador do sistema.'));
     }
     return new ViewModel(['registration' => $registration, 'form' => $form, 'message' => '']);
 }
コード例 #28
0
 public function loginuserAction()
 {
     /*
         pour le login on prepare la form et en test si il y a une post method 
         si /oui on test les information 
         si /non redirection vers l'index est affichage de la form
     */
     $request = $this->getRequest();
     $session = new Container('useradmin');
     if ($session->offsetExists('uid') && $session->offsetExists('ucomp') && $session->offsetGet('user') == 'user') {
         $this->redirect()->toRoute('useradmin', array('action' => 'index'));
     }
     if ($request->isPost()) {
         $password = $this->getRequest()->getPost('password');
         $email = $this->getRequest()->getPost('email');
         $adapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter');
         $sql = "select pu.id,pu.name,pu.company,pu.active,pu.admin,pu.email,pu.passwd FROM pro_user pu where pu.email='" . $email . "' and pu.passwd='" . $password . "' and pu.admin=1 and pu.active=1";
         $statement = $adapter->query($sql);
         $results = $statement->execute();
         $row = $results->current();
         if (!$row) {
             $this->redirect()->toRoute('useradmin', array('action' => 'loginuser'), array('query' => array('status' => 'filed_login')));
         } else {
             if ($row['admin'] != 1 && $row['active'] != 1) {
                 $this->redirect()->toRoute('useradmin', array('action' => 'loginuser'), array('query' => array('status' => 'no_permission')));
             }
             // collection des information
             $uid = $row['id'];
             $uprenom = $row['name'];
             $uemail = $row['email'];
             $ucomp = $row['company'];
             $session->offsetSet('user', 'user');
             $session->offsetSet('uid', $uid);
             $session->offsetSet('uprenom', $uprenom);
             $session->offsetSet('uemail', $uemail);
             $session->offsetSet('ucomp', $ucomp);
             $session = new Container('admin');
             $session->getManager()->getStorage()->clear('admin');
             $this->redirect()->toRoute('useradmin', array('action' => 'index'));
         }
     }
     //return new ViewModel();
 }
コード例 #29
0
 public function filterAction()
 {
     $ssFilter = new Container($this->_namespace);
     $purifier = new \HTMLPurifier_HTMLPurifier();
     if ($this->_arrParam['type'] == 'search') {
         if ($this->_arrParam['col'] == 'null' && $this->_arrParam['by'] == 'null' && $this->_arrParam['key'] == 1) {
             if ($this->params()->fromPost('keywords') != '') {
                 $ssFilter->keywords = $purifier->purify(trim($this->params()->fromPost('keywords')));
                 $ssFilter->field = $this->params()->fromPost('field');
             }
             $ssFilter->status = $this->params()->fromPost('status');
             $ssFilter->city = $this->params()->fromPost('city_id');
             $ssFilter->group = $this->params()->fromPost('group_id');
         }
         if ($this->_arrParam['col'] == 'null' && $this->_arrParam['by'] == 'null' && $this->_arrParam['key'] == 0) {
             $ssFilter->getManager()->getStorage()->clear();
         }
     }
     if ($this->_arrParam['type'] == 'order' && $this->_arrParam['col'] != 'null' && $this->_arrParam['by'] != 'null') {
         $ssFilter->col = $this->_arrParam['col'];
         $ssFilter->order = $this->_arrParam['by'];
     }
     if ($this->_arrParam['type'] == 'record') {
         $ssFilter->record = $this->params()->fromPost('record');
     }
     $this->redirect()->toUrl('/admin/legislationhousing/');
     return $this->getResponse();
 }
コード例 #30
0
ファイル: AuthController.php プロジェクト: zfury/cmf
 /**
  * @return \Zend\Http\Response|ViewModel
  * @throws \Exception
  */
 public function recoverPasswordAction()
 {
     if (!($confirm = $this->params('hash'))) {
         $this->flashMessenger()->addErrorMessage('Invalid code!');
         return $this->redirect()->toRoute('home');
     }
     $form = new Form\SetNewPasswordForm('set-new-password', ['serviceLocator' => $this->getServiceLocator()]);
     if ($this->getRequest()->isPost()) {
         $form->setData($this->getRequest()->getPost());
         if ($form->isValid()) {
             $userService = new \User\Service\User($this->getServiceLocator());
             $objectManager = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager');
             /** @var \User\Entity\User $user */
             $user = $objectManager->getRepository('User\\Entity\\User')->findOneBy(array('confirm' => $confirm));
             if (!$user) {
                 throw new \Exception('Invalid confirmation code');
             }
             try {
                 $userService->changePassword($user, $form);
                 $user->setConfirm(null);
                 $objectManager->persist($user);
                 $objectManager->flush();
                 $this->flashMessenger()->addSuccessMessage('You have successfully changed your password!');
                 $criteria = Criteria::create()->where(Criteria::expr()->eq('provider', 'equals'));
                 $user->getAuths()->matching($criteria)->first()->login($this->getServiceLocator());
                 $session = new Container('location');
                 $location = $session->location;
                 if ($location) {
                     $session->getManager()->getStorage()->clear('location');
                     return $this->redirect()->toUrl($location);
                 }
                 return $this->redirect()->toRoute('home');
             } catch (\Exception $exception) {
                 throw $exception;
             }
         }
     }
     return new ViewModel(array('form' => $form));
 }