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]); }
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; } */ }
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)); }
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(); } }
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)); }
public function logoutAction() { $auth = new AuthenticationService(); $auth->setStorage(new SessionStorage('SONUser')); $auth->clearIdentity(); return $this->redirect()->toRoute('sonuser-auth'); }
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'); } }
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; })); }
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)); }
/** * 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'); }
public function logoutAction() { $auth = new AuthenticationService(); $auth->setStorage(new SessionStorage("auth_enquete")); $auth->clearIdentity(); $this->redirect()->toRoute("auth"); }
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; })); }
public function logoutAction() { $auth = new AuthenticationService(); $auth->setStorage(new SessionStorage("geframa_admin")); $auth->clearIdentity(); return $this->redirect()->toRoute('geframa_login'); }
public function validaAuth($e) { $auth = new AuthenticationService(); $auth->setStorage(new SessionStorage("SONUSer")); $controller = $e->getTarget(); $matchedRoute = $controller->getEvent()->getRouteMatch()->getMatchedRouteName(); }
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; })); }
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'); }
public function validaAuth($e) { $auth = new AuthenticationService(); $auth->setStorage(new SessionStorage("SONUSer")); $controller = $e->getTarget(); $matchedRoute = $controller->getEvent()->getRouteMatch()->getMatchedRouteName(); #if(!$auth->hasIdentity() and ($matchedRoute == "sonuser-admin" OR $matchedRoute == "sonuser-admin/paginator")) # return $controller->redirect()->toRoute("sonuser-auth"); }
public function createService(ServiceLocatorInterface $servicelocator) { $dbAdapter = $servicelocator->get('Zend\\Db\\Adapter\\Adapter'); $dbTableAuthAdapter = new DbTable($dbAdapter, 'user', 'username', 'password', 'MD5(?)'); $authService = new AuthenticationService(); $authService->setAdapter($dbTableAuthAdapter); $authService->setStorage(new MyAuthStorage()); return $authService; }
/** * * @param unknown $data */ public static function setUser($data) { if (SESSION_KEY == "") { die("You must define some random SESSION_KEY in Index.php"); } $auth = new AuthenticationService(); $auth->setStorage(new \Zend\Authentication\Storage\Session(SESSION_KEY ? SESSION_KEY : "")); $auth->getStorage()->write($data); }
public function createService(ServiceLocatorInterface $serviceLocator) { $storage = $serviceLocator->get('auth_storage'); if ($storage instanceof StorageInterface) { $service = new AuthenticationService(); $service->setStorage($storage); return $service; } throw new \RuntimeException('Could not get StorageInterface service instance.'); }
/** * Method that new defined classes into the service locator * @return array * @throws \Zend\Db\ResultSet\Exception\InvalidArgumentException * @throws \Zend\Db\TableGateway\Exception\InvalidArgumentException */ public function getServiceConfig() { return array('abstract_factories' => array(), 'aliases' => array(), 'factories' => array('RememberMeStorage' => function () { return new RememberMeStorage(); }, 'AuthService' => function ($sm) { $authService = new AuthenticationService(); $authService->setStorage($sm->get('RememberMeStorage')); return $authService; }), 'invokables' => array(), 'services' => array(), 'shared' => array()); }
public function userAuth($e) { $auth = new AuthenticationService(); $auth->setStorage(new SessionStorage("SONUser")); $controller = $e->getTarget(); $matchedRoute = $controller->getEvent()->getRouteMatch()->getMatchedRouteName(); if (!$auth->hasIdentity() and (strpos($matchedRoute, "sonbase-admin") !== false or strpos($matchedRoute, "sonuser-admin") !== false or strpos($matchedRoute, "sonacl-admin") !== false)) { return $controller->redirect()->toRoute('sonuser-auth'); } }
public function validAuth($e) { $auth = new AuthenticationService(); $auth->setStorage(new SessionStorage("User")); $controller = $e->getTarget(); $matchedRoute = $controller->getEvent()->getRouteMatch()->getMatchedRouteName(); if (!$auth->hasIdentity() && ($matchedRoute == 'user-admin' || $matchedRoute == 'user-admin/paginator')) { return $controller->redirect()->toRoute('user-auth'); } }
public function createService(ServiceLocatorInterface $serviceLocator) { $dbAdapter = $serviceLocator->get('ZendDbAdapter'); $authStorage = $serviceLocator->get('AdminAuthStorage'); $authAdapter = new DbTable($dbAdapter, 'Users', 'username', 'password', 'MD5(?)'); $authService = new AuthenticationService(); $authService->setAdapter($authAdapter); $authService->setStorage($authStorage); return $authService; }
public function getServiceConfig() { return array("factories" => array("DoctrineAuth\\Model\\MyAuthStorage" => function ($serviceManager) { return new \DoctrineAuth\Model\MyAuthStorage("myauthstorage"); }, "AuthService" => function ($serviceManager) { $authService = new AuthenticationService(); $authService->setStorage($serviceManager->get('DoctrineAuth\\Model\\MyAuthStorage')); return $serviceManager->get('doctrine.authenticationservice.orm_default'); })); }
public function validaAuth($e) { $auth = new AuthenticationService(); $auth->setStorage(new SessionStorage("SONUser")); $controller = $e->getTarget(); $matchedRoute = $controller->getEvent()->getRouteMatch()->getMatchedRouteName(); if (!$auth->hasIdentity() && strstr($matchedRoute, 'sonuser-admin') != false) { $controller->redirect()->toRoute('sonuser-auth'); } }
public function authenticate() { $result = new Result(1, 1, array(1 => 'Witaj ' . $this->username)); $ses = new SessionStorage(); $ses->write($result); $auth = new AuthenticationService(); // Use 'someNamespace' instead of 'Zend_Auth' $auth->setStorage(new SessionStorage('someNamespace')); var_dump($auth->getStorage()->read()); return $result; }
public function verificaIdentidade(EventInterface $e) { $auth = new AuthenticationService(); $auth->setStorage(new SessionStorage('FuncSessao')); $controller = $e->getTarget(); // var_dump($controller->getMvcEvent()->getController()->redirect()->toRoute('a')); $matchedRoute = $controller->getEvent()->getRouteMatch()->getMatchedRouteName(); // var_dump($matchedRoute); if (!$auth->hasIdentity() && ($matchedRoute == "application/default" || $matchedRoute == "home")) { return $controller->redirect()->toRoute('application-auth'); } }
public function getServiceConfig() { return array('factories' => array('User\\Model\\MyAuthStorage' => function ($sm) { return new \User\Model\MyAuthStorage('zf_tutorial'); }, 'AuthService' => function ($sm) { $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter'); $dbTableAuthAdapter = new DbTableAuthAdapter($dbAdapter, 't_usuarios_servidorlocal', 'USER_NAME', 'PASSWORD'); $authService = new AuthenticationService(); $authService->setAdapter($dbTableAuthAdapter); $authService->setStorage($sm->get('User\\Model\\MyAuthStorage')); return $authService; }, 'UserFunctions' => function ($sm) { $UserFunctions = new UserFunctions($sm); return $UserFunctions; }, 'UserTableGateway' => function ($sm) { $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter'); $resultSetPrototype = new ResultSet(); $resultSetPrototype->setArrayObjectPrototype(new User()); return new TableGateway('t_usuarios_servidorlocal', $dbAdapter, null, $resultSetPrototype); }, 'AdminTableGateway' => function ($sm) { $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter'); $resultSetPrototype = new ResultSet(); $resultSetPrototype->setArrayObjectPrototype(new Admin()); return new TableGateway('t_adminlocales', $dbAdapter, null, $resultSetPrototype); }, 'SponsorTableGateway' => function ($sm) { $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter'); $resultSetPrototype = new ResultSet(); $resultSetPrototype->setArrayObjectPrototype(new SponsorLocal()); return new TableGateway('t_sponsorslocales', $dbAdapter, null, $resultSetPrototype); }, 'DuenoTableGateway' => function ($sm) { $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter'); $resultSetPrototype = new ResultSet(); $resultSetPrototype->setArrayObjectPrototype(new DuenoLocal()); return new TableGateway('t_duenoslocales', $dbAdapter, null, $resultSetPrototype); }, 'CampaignTableGateway' => function ($sm) { $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter'); $resultSetPrototype = new ResultSet(); $resultSetPrototype->setArrayObjectPrototype(new Campaign()); return new TableGateway('t_campanassponsorlocal', $dbAdapter, null, $resultSetPrototype); }, 'PromoTableGateway' => function ($sm) { $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter'); $resultSetPrototype = new ResultSet(); $resultSetPrototype->setArrayObjectPrototype(new Promo()); return new TableGateway('t_publicidadeslocales', $dbAdapter, null, $resultSetPrototype); }, 'controlsSPONSOR_LOCAL' => function ($sm) { return new \User\Model\SponsorControls(); }, 'controlsDUENO_LOCAL' => function ($sm) { return new \User\Model\DuenoControls(); }, 'controlsADMIN' => function ($sm) { return new \User\Model\AdminControls(); })); }