当前位置: 首页>>代码示例>>PHP>>正文


PHP AuthenticationService::setStorage方法代码示例

本文整理汇总了PHP中Zend\Authentication\AuthenticationService::setStorage方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthenticationService::setStorage方法的具体用法?PHP AuthenticationService::setStorage怎么用?PHP AuthenticationService::setStorage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Authentication\AuthenticationService的用法示例。


在下文中一共展示了AuthenticationService::setStorage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loginAction

 public function loginAction()
 {
     if ($this->authenticationService->hasIdentity()) {
         return $this->redirect()->toRoute('dashboard');
     }
     $storage = $this->authenticationService->getStorage();
     $this->authenticationService->setStorage(new NonPersistent());
     $redir = $this->params()->fromQuery('redir', $this->params()->fromPost('redir'));
     if ($redir !== null) {
         $this->authSession->url = $redir;
         return $this->redirect()->toRoute('login');
     }
     if ($this->getRequest()->isPost()) {
         $this->authenticateForm->setData($this->getRequest()->getPost());
         if ($this->authenticateForm->isValid()) {
             /** @var AccountInterface $account */
             $account = $this->zourceAccount();
             $this->authSession->identity = $this->identity();
             $this->authSession->verified = false;
             $this->authenticationService->setStorage($storage);
             return $this->redirectAfterLogin($account);
         }
     }
     $this->resetTwoFactorAuthentication();
     return new ViewModel(['authenticateForm' => $this->authenticateForm]);
 }
开发者ID:zource,项目名称:zource,代码行数:26,代码来源:Authenticate.php

示例2: validaAuth

 public function validaAuth($e)
 {
     $sessionStorage = new SessionStorage("geframa_admin");
     $authService = new AuthenticationService();
     $authService->setStorage($sessionStorage);
     $controller = $e->getTarget();
     $matchedRoute = $controller->getEvent()->getRouteMatch()->getMatchedRouteName();
     //        die("<pre>" . __FILE__ . "\nLinha " . __LINE__ . "\n\n" . \Zend\Debug\Debug::dump($matchedRoute) . "</pre>");
     if (!$authService->hasIdentity() and !(strpos($matchedRoute, 'geframa_login') === 0 || strpos($matchedRoute, 'layout_') === 0 || strpos($matchedRoute, 'core_') === 0)) {
         //         die("<pre>" . __FILE__ . "\nLinha " . __LINE__ . "\n\n" . print_r($matchedRoute, 1) . "</pre>");
         return $controller->redirect()->toRoute("geframa_login");
     }
     /*
            $sessionStorage = new SessionStorage($namespace);
            $this->authService = new AuthenticationService;
            $this->authService->setStorage($sessionStorage);
     
            if ($this->getAuthService()->hasIdentity()) {
                return $this->getAuthService()->getIdentity();
            }
            else {
                return false;
            }
     */
 }
开发者ID:phtfao,项目名称:geframa,代码行数:25,代码来源:Module.php

示例3: indexAction

 public function indexAction()
 {
     $form = new LoginForm();
     $error = false;
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $data = $request->getPost()->toArray();
         }
         $auth = new AuthenticationService();
         $sessionStorage = new SessionStorage("Application");
         $auth->setStorage($sessionStorage);
         $authAdapter = $this->getServiceLocator()->get('Application\\Auth\\DoctrineAdapter');
         $authAdapter->setUsername($data['email'])->setPassword($data['password']);
         $result = $auth->authenticate($authAdapter);
         if ($result->isValid()) {
             $sessionStorage->write($auth->getIdentity()['user'], null);
             return $this->redirect()->toRoute("Application", array('controller' => 'IndexController', 'action' => 'index'));
         } else {
             $error = true;
         }
     }
     return new ViewModel(array('form' => $form, 'error' => $error));
 }
开发者ID:AgnaldoJaws,项目名称:CredentialFaces,代码行数:25,代码来源:AuthController.php

示例4: validAuthAcl

 public function validAuthAcl($e)
 {
     $storage = new SessionStorage();
     $auth = new AuthenticationService();
     $auth->setStorage($storage);
     //pega controller e action
     $controller = $e->getTarget();
     $em = $controller->getServiceLocator()->get('Doctrine\\ORM\\EntityManager');
     $matchedRoute = $controller->getEvent()->getRouteMatch()->getMatchedRouteName();
     $matchedController = $controller->getEvent()->getRouteMatch()->getParam('controller');
     $matchedAction = $controller->getEvent()->getRouteMatch()->getParam('action', 'index');
     //user logado
     if ($auth->hasIdentity()) {
         $arrayUser = $auth->getIdentity();
         $repository = $em->getRepository("Zf2User\\Entity\\User");
         $user = $repository->findOneById($arrayUser->getId());
         $role = $user->getRole()->getName();
     } elseif (!$auth->hasIdentity()) {
         $role = 'Visit';
     }
     //acl
     $acl = $controller->getServiceLocator()->get("Zf2Acl\\Permissions\\Acl");
     if (!$acl->isAllowed($role, $matchedController, $matchedAction)) {
         $e->getResponse()->setStatusCode(Response::STATUS_CODE_404);
         $e->stopPropagation();
     }
 }
开发者ID:jhonmike,项目名称:zf-user,代码行数:27,代码来源:Module.php

示例5: indexAction

 public function indexAction()
 {
     $form = new LoginForm();
     $error = false;
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $data = $request->getPost()->toArray();
             // Criando Storage para gravar sessão da authtenticação
             $sessionStorage = new SessionStorage();
             $auth = new AuthenticationService();
             $auth->setStorage($sessionStorage);
             // Definindo o SessionStorage para a auth
             $authAdapter = $this->getServiceLocator()->get("ACPLOUser\\Auth\\Adapter");
             $authAdapter->setUsername($data['email']);
             $authAdapter->setPassword($data['password']);
             $result = $auth->authenticate($authAdapter);
             if ($result->isValid()) {
                 $user = $auth->getIdentity();
                 $user = $user['user'];
                 $sessionStorage->write($user, null);
                 #$sessionStorage->write($auth->getIdentity()['user'],null);
                 return $this->redirect()->toRoute('acplouser-admin/default', array('controller' => 'users'));
             } else {
                 $error = true;
             }
         }
     }
     return new ViewModel(array('form' => $form, 'error' => $error));
 }
开发者ID:abelclopes,项目名称:ZF2-Intermediario-com-acl,代码行数:31,代码来源:AuthController.php

示例6: logoutAction

 public function logoutAction()
 {
     $auth = new AuthenticationService();
     $auth->setStorage(new SessionStorage('SONUser'));
     $auth->clearIdentity();
     return $this->redirect()->toRoute('sonuser-auth');
 }
开发者ID:Tortinhex,项目名称:son-zf2-inter,代码行数:7,代码来源:AuthController.php

示例7: indexAction

 public function indexAction()
 {
     try {
         $request = $this->getRequest();
         if ($request->isPost()) {
             $data = $request->getPost();
             $auth = new AuthenticationService();
             $sessionStorage = new SessionStorage();
             $auth->setStorage($sessionStorage);
             $authAdapter = $this->getServiceLocator()->get('Application\\Model\\Adapter');
             $authAdapter->setName($data['userName']);
             $authAdapter->setPassword($data['password']);
             $result = $auth->authenticate($authAdapter);
             $user = $result->getIdentity()['user'];
             if ($result->isValid()) {
                 $this->session = new Container('App_Auth');
                 $this->session->user = $result->getIdentity()['user'];
                 $this->session->selectedPill = 1;
                 return $this->redirect()->toUrl('/home');
             } else {
                 return $this->errorMessage('Usuário ou senha inválidos', '/login');
             }
         } else {
             if ($this->isLogged()) {
                 return $this->redirect()->toUrl('/home');
             }
             return array();
         }
     } catch (\Exception $e) {
         return $this->errorMessage('Não foi possível realizar o login', '/login');
     }
 }
开发者ID:MarceloPilatti,项目名称:oficinaderecreacao-site-zend,代码行数:32,代码来源:AuthController.php

示例8: getServiceConfig

 public function getServiceConfig()
 {
     return array('factories' => array('Album\\Model\\AlbumTable' => function ($sm) {
         $tableGateway = $sm->get('AlbumTableGateway');
         $table = new AlbumTable($tableGateway);
         return $table;
     }, 'AlbumTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Album());
         return new TableGateway('z_album', $dbAdapter, null, $resultSetPrototype);
     }, 'Album\\Model\\MyAuthStorage' => function ($sm) {
         return new \Album\Model\MyAuthStorage('Album');
     }, 'AuthService' => function ($sm) {
         //My assumption, you've alredy set dbAdapter
         //and has users table with columns : user_name and pass_word
         //that password hashed with md5
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $dbTableAuthAdapter = new DbTableAuthAdapter($dbAdapter, 'z_user', 'user_name', 'password', "sha(CONCAT(sha(?), '{$this->_salt}'))");
         $authService = new AuthenticationService();
         $authService->setAdapter($dbTableAuthAdapter);
         $authService->setStorage($sm->get('Album\\Model\\MyAuthStorage'));
         return $authService;
     }));
 }
开发者ID:Embraser01,项目名称:IUT-ProjetWeb-TP1,代码行数:25,代码来源:Module.php

示例9: loginAction

 public function loginAction()
 {
     $messages = null;
     $isAuth = false;
     $form = new LoginForm();
     $auth = new AuthenticationService();
     $sessionStorage = new SessionStorage("Login");
     $request = $this->getRequest();
     if ($request->isPost()) {
         $data = $request->getPost()->toArray();
         $form->setData($data);
         if ($form->isValid()) {
             $auth->setStorage($sessionStorage);
             $authAdapter = $this->getPluginManager()->getServiceLocator()->get('VMBLogin\\Auth\\Adapter');
             $authAdapter->setUsername($data['username'])->setPassword($data['password']);
             $result = $auth->authenticate($authAdapter);
             if ($result->isValid()) {
                 $sessionStorage->write($auth->getIdentity()['user'], null);
                 $messages = "you are now authenticated";
                 $isAuth = true;
             } else {
                 $messages = "username or password is incorrect";
             }
         }
     }
     return new ViewModel(array('form' => $form, 'messages' => $messages, 'auth' => $isAuth));
 }
开发者ID:vitorbarros,项目名称:vmb-zf2-module-login,代码行数:27,代码来源:LoginController.php

示例10: logoutAction

 /**
  * Logout user
  *
  * @return \Zend\Http\Response
  */
 public function logoutAction()
 {
     $auth = new AuthenticationService();
     $auth->setStorage(new SessionStorage('BookstoreAdmin'));
     $auth->clearIdentity();
     return $this->redirect()->toRoute('bookstore-admin-auth');
 }
开发者ID:argentinaluiz,项目名称:Learning-ZF2,代码行数:12,代码来源:AuthController.php

示例11: logoutAction

 public function logoutAction()
 {
     $auth = new AuthenticationService();
     $auth->setStorage(new SessionStorage("auth_enquete"));
     $auth->clearIdentity();
     $this->redirect()->toRoute("auth");
 }
开发者ID:felipe1070,项目名称:testeXyz,代码行数:7,代码来源:AuthController.php

示例12: getServiceConfig

 public function getServiceConfig()
 {
     return array('factories' => array('Zend\\Db\\Adapter\\Adapter' => 'Zend\\Db\\Adapter\\AdapterServiceFactory', 'SanAuth\\Model\\MyAuthStorage' => function ($sm) {
         return new \SanAuth\Model\MyAuthStorage('zf_tutorial');
     }, 'AuthService' => function ($sm) {
         $dbTableAuthAdapter = $sm->get('TableAuthService');
         $authService = new AuthenticationService();
         $authService->setStorage(new \Zend\Authentication\Storage\Session('Auth'));
         // $authService->setStorage($sm->get('SanAuth\Model\MyAuthStorage')); //
         $authService->setAdapter($dbTableAuthAdapter);
         return $authService;
     }, 'AuthService2' => function ($sm) {
         $dbTableAuthAdapter = $sm->get('TableAuth2Service');
         $authService = new AuthenticationService();
         $authService->setStorage(new \Zend\Authentication\Storage\Session('Auth'));
         // $authService->setStorage($sm->get('SanAuth\Model\MyAuthStorage')); //
         $authService->setAdapter($dbTableAuthAdapter);
         return $authService;
     }, 'TableAuthService' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $dbTableAuthAdapter = new DbTableAuthAdapter($dbAdapter, 'ta_cliente', 'va_email', 'va_contrasena', 'SHA1(?)');
         //
         return $dbTableAuthAdapter;
     }, 'TableAuth2Service' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $dbTableAuthAdapter = new DbTableAuthAdapter($dbAdapter, 'ta_cliente', 'va_email', 'va_contrasena_facebook', 'SHA1(?)');
         //
         return $dbTableAuthAdapter;
     }));
 }
开发者ID:kevcast,项目名称:lsrefactoring,代码行数:30,代码来源:Module.php

示例13: validaAuth

 public function validaAuth($e)
 {
     $auth = new AuthenticationService();
     $auth->setStorage(new SessionStorage("SONUSer"));
     $controller = $e->getTarget();
     $matchedRoute = $controller->getEvent()->getRouteMatch()->getMatchedRouteName();
 }
开发者ID:feijojr,项目名称:EADGestao,代码行数:7,代码来源:Module.php

示例14: getServiceConfig

 public function getServiceConfig()
 {
     return array('factories' => array('Admin\\Model\\AdminTable' => function ($sm) {
         $tableGateway = $sm->get('AdminTableGateway');
         $table = new AdminTable($tableGateway);
         return $table;
     }, 'AdminTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Admin());
         return new TableGateway('admin', $dbAdapter, null, $resultSetPrototype);
     }, 'Admin\\Model\\PlayerTable' => function ($sm) {
         $tableGateway = $sm->get('PlayerTableGateway');
         $table = new PlayerTable($tableGateway);
         return $table;
     }, 'PlayerTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Player());
         return new TableGateway('player', $dbAdapter, null, $resultSetPrototype);
     }, 'Admin\\Model\\MyAuthStorage' => function ($sm) {
         return new \Admin\Model\MyAuthStorage('adminstore');
     }, 'AuthService' => function ($sm) {
         //My assumption, you've alredy set dbAdapter
         //and has users table with columns : user_name and pass_word
         //that password hashed with md5
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $dbTableAuthAdapter = new DbTableAuthAdapter($dbAdapter, 'admin', 'email', 'password', 'MD5(?)');
         $authService = new AuthenticationService();
         $authService->setAdapter($dbTableAuthAdapter);
         $authService->setStorage($sm->get('Admin\\Model\\MyAuthStorage'));
         return $authService;
     }));
 }
开发者ID:bladehr8,项目名称:bowhunter2015,代码行数:34,代码来源:Module.php

示例15: logoutAction

 public function logoutAction()
 {
     $auth = new AuthenticationService();
     $auth->setStorage(new SessionStorage('FuncSessao'));
     #Definindo session storage pra auth
     $auth->clearIdentity();
     return $this->redirect()->toUrl('/application/auth/index');
 }
开发者ID:projetopim2015job,项目名称:homologacao,代码行数:8,代码来源:AuthController.php


注:本文中的Zend\Authentication\AuthenticationService::setStorage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。