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


PHP Zend_Auth_Adapter_DbTable::setIdentity方法代码示例

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


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

示例1: authenticate

 /**
  * @param string $uname
  * @param string $password 
  * @return bool True iff login attempt was successful
  */
 public function authenticate($uname, $password)
 {
     self::$_authAdapter->setIdentity($uname)->setCredential($password);
     //        $zendAuthInstance = Zend_Auth::getInstance();
     //        $zendAuthInstance->setStorage(new Zend_Auth_Storage_Session('prosecco'));
     return Zend_Auth::getInstance()->authenticate(self::$_authAdapter)->isValid();
 }
开发者ID:rindPHI,项目名称:ProSecCo,代码行数:12,代码来源:Authentication.php

示例2: authenticate

 /**
  * 
  * @throws Zend_Auth_Adapter_Exception If authentication cannot be performed 
  * @return Zend_Auth_Result 
  * @see Zend_Auth_Adapter_Interface::authenticate()
  */
 public function authenticate()
 {
     $result = array('code' => Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND, 'identity' => null, 'messages' => array());
     /** @var Zend_Config */
     $config = Zend_Registry::get('config');
     if (isset($config['admin']['pass']) && $this->_data['code'] == $config['admin']['pass'] && $this->_data['email'] == 'admin') {
         $result['code'] = Zend_Auth_Result::SUCCESS;
         $result['identity'] = new Reg2_Model_Identity('admin');
         Zend_Registry::get('log')->info('Admin login from ' . $_SERVER['REMOTE_ADDR']);
         return new Zend_Auth_Result($result['code'], $result['identity'], $result['messages']);
     }
     $this->_dbauth->setIdentity($this->_data['email'])->setCredential($this->_data['code']);
     $dbresult = $this->_dbauth->authenticate();
     if ($dbresult->isValid()) {
         $result['code'] = Zend_Auth_Result::SUCCESS;
         $user = $this->_dbauth->getResultRowObject();
         $result['identity'] = new Reg2_Model_Identity($user->role, $user);
         Zend_Registry::get('log')->info(sprintf("Login with '%s' as '%s'(%d) from %s", $this->_data['email'], $user->role, $user->tid, $_SERVER['REMOTE_ADDR']));
     } else {
         $result['code'] = $dbresult->getCode();
         $result['messages'] = $dbresult->getMessages();
         Zend_Registry::get('log')->info(sprintf("Login attempt: %d from %s", $dbresult->getCode(), $_SERVER['REMOTE_ADDR']));
     }
     return new Zend_Auth_Result($result['code'], $result['identity'], $result['messages']);
 }
开发者ID:smalyshev,项目名称:chgk-teams,代码行数:31,代码来源:Adapter.php

示例3: _getAuthAdapter

 protected function _getAuthAdapter($identity, $credential)
 {
     if ($this->_authAdapter === null) {
         $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
         $dbConfig = $dbAdapter->getConfig();
         $this->_authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
         $this->_authAdapter->setTableName($dbConfig['prefix'] . 'users')->setIdentityColumn('email')->setCredentialColumn('password')->setCredentialTreatment('MD5(?)')->getDbSelect()->where('active = ?', true);
         $this->_authAdapter->setIdentity($identity)->setCredential($credential);
     }
     return $this->_authAdapter;
 }
开发者ID:robertbasic,项目名称:phpplaneta,代码行数:11,代码来源:Auth.php

示例4: loginWithoutPassword

 public function loginWithoutPassword($login)
 {
     self::$_authAdapter->setIdentity($login)->setCredentialColumn('login')->setCredentialTreatment('?')->setCredential($login);
     $auth = Zend_Auth::getInstance();
     if ($auth->authenticate(self::$_authAdapter)->isValid()) {
         return true;
     } else {
         $this->login();
         //			self::$_authAdapter->setIdentity('guest')->setCredential('');
         //			$auth->authenticate(self::$_authAdapter);
     }
     return false;
 }
开发者ID:Konstnantin,项目名称:zf-app,代码行数:13,代码来源:Auth.php

示例5: isValid

 public function isValid($value, $context = null)
 {
     $value = (string) $value;
     $this->_setValue($value);
     $this->_authAdapter->setIdentity($context[$this->_identityElement]);
     $this->_authAdapter->setCredential($value);
     $result = Zend_Auth::getInstance()->authenticate($this->_authAdapter);
     if ($result->isValid()) {
         Zend_Auth::getInstance()->getStorage()->write($this->_authAdapter->getResultRowObject(null, 'pwd'));
         return true;
     }
     $this->_error(self::LOGIN_FAILS);
     return false;
 }
开发者ID:josmel,项目名称:DevelEntretenimientoEntel,代码行数:14,代码来源:Auth.php

示例6: loginAction

 public function loginAction()
 {
     // action body
     $request = $this->getRequest();
     $form = new Application_Form_Login();
     if ($request->isPost()) {
         if ($form->isValid($request->getPost())) {
             $bootstrap = $this->getInvokeArg('bootstrap');
             $dbAdapter = $bootstrap->getResource('db');
             $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter, 'user', 'name', 'password');
             $data = $form->getValidValues($request->getPost());
             $authAdapter->setIdentity($data['name']);
             $password = sha1($data['password']);
             $authAdapter->setCredential($password);
             $auth = Zend_Auth::getInstance();
             $result = $auth->authenticate($authAdapter);
             if ($result->isValid()) {
                 $user = $authAdapter->getResultRowObject(null, 'password');
                 $storage = $auth->getStorage();
                 $storage->write($user);
                 if ($user->confirmed == 1) {
                     $this->_redirect('dashboard');
                     // Redirect to dashboard
                 } else {
                     Zend_Auth::getInstance()->clearIdentity();
                     $this->view->errors = array('You\'re registration is not yet confirmed');
                 }
             } else {
                 $form->getElement('password')->addError('Invalid password.');
             }
         }
     }
     $this->view->form = $form;
 }
开发者ID:jingjangjung,项目名称:WinsAndWants,代码行数:34,代码来源:AuthController.php

示例7: indexAction

 public function indexAction()
 {
     $form = new Application_Form_Login();
     $request = $this->getRequest();
     if ($request->isPost()) {
         //      if ($form->isValid($this->_getAllParams()))
         if ($form->isValid($request->getPost())) {
             $dbAdapter = Zend_Db_Table::getDefaultAdapter();
             $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
             $authAdapter->setTableName('smo_usuario')->setIdentityColumn('usu_rut')->setCredentialColumn('usu_passwd')->setCredentialTreatment('md5(CONCAT(?,usu_passwd_salt))');
             $authAdapter->setIdentity($form->getValue('rut'))->setCredential($form->getValue('pass'));
             $auth = Zend_Auth::getInstance();
             $result = $auth->authenticate($authAdapter);
             if ($result->isValid()) {
                 // get all info about this user from the login table  // ommit only the password, we don't need that
                 $userInfo = $authAdapter->getResultRowObject(null, 'password');
                 // the default storage is a session with namespace Zend_Auth
                 $authStorage = $auth->getStorage();
                 $authStorage->write($userInfo);
                 return $this->_helper->redirector->gotoSimple('index', 'index');
                 //$this->_redirect('view/index/index');
             } else {
                 $errorMessage = "Datos Incorrectos, intente de nuevo.";
             }
         }
     }
     $this->view->form = $form;
     $this->view->errorMessage = $errorMessage;
 }
开发者ID:BGCX262,项目名称:zsmo-git,代码行数:29,代码来源:LoginController.php

示例8: login

 public function login($arrParam = null, $options = null)
 {
     //1. Lay ket noi voi database
     $db = Zend_Registry::get("connectDB");
     //2.
     $authAdapter = new Zend_Auth_Adapter_DbTable($db);
     $authAdapter->setTableName('user')->setIdentityColumn('user_name')->setCredentialColumn('password');
     //3.
     $authAdapter->setIdentity($arrParam['user_name']);
     $password = md5($arrParam['password']);
     $authAdapter->setCredential($password);
     //4.
     $select = $authAdapter->getDbSelect();
     $select->where("status = 1");
     //5.
     $auth = Zend_Auth::getInstance();
     $result = $auth->authenticate($authAdapter);
     $flag = false;
     if ($result->isValid()) {
         $returnColumns = array('user_name', 'password');
         $omitColumns = array('password');
         $data = $authAdapter->getResultRowObject(null, $omitColumns);
         $auth->getStorage()->write($data);
         $flag = true;
     } else {
         $this->_messages = $result->getMessages();
     }
     return $flag;
 }
开发者ID:backviet01,项目名称:zegome-service,代码行数:29,代码来源:Auth.php

示例9: loginAction

 public function loginAction()
 {
     //Desabilita renderização da view
     $this->_helper->viewRenderer->setNoRender();
     //Obter o objeto do adaptador para autenticar usando banco de dados
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
     //Seta qual tabela e colunas procurar o usuário
     $authAdapter->setTableName('usuario')->setIdentityColumn('login')->setCredentialColumn('senha');
     //Seta as credenciais com dados vindos do formulário de login
     $authAdapter->setIdentity($this->_getParam('login'))->setCredential($this->_getParam('senha'))->setCredentialTreatment('MD5(?)');
     //Realiza autenticação
     $result = $authAdapter->authenticate();
     //Verifica se a autenticação foi válida
     if ($result->isValid()) {
         //Obtém dados do usuário
         $usuario = $authAdapter->getResultRowObject();
         //Armazena seus dados na sessão
         $storage = Zend_Auth::getInstance()->getStorage();
         $storage->write($usuario);
         //Redireciona para o Index
         $this->_redirect('index');
     } else {
         $this->_redirect('autenticacao/falha');
     }
 }
开发者ID:lincolnfatal,项目名称:projetos,代码行数:26,代码来源:AutenticacaoController.php

示例10: validateUserLocal

 /**
  * @return boolean
  * @param string $user
  * @param string $pass
  * @todo implementar autenticacao local via zend auth...
  */
 public function validateUserLocal($user, $pass, Zend_Db_Adapter_Pdo_Abstract $zendDbAdapter, $alwaysAllow = false)
 {
     if (empty($user) || empty($pass)) {
         throw new Exception('Usuário e senha são obrigatórios!');
     }
     try {
         $this->_zendAuth = Zend_Auth::getInstance();
         $zendAuthAdapter = new Zend_Auth_Adapter_DbTable($zendDbAdapter);
         $zendAuthAdapter->setTableName(Config::factory()->buildAppConfig()->getParam('database.default.schema') . '.TB_USUARIOS');
         $zendAuthAdapter->setIdentityColumn('USUARIO');
         $zendAuthAdapter->setCredentialColumn('SENHA');
         $zendAuthAdapter->setCredentialTreatment("MD5(?)");
         $zendAuthAdapter->setIdentity($user);
         $zendAuthAdapter->setCredential($pass);
         if ($alwaysAllow) {
             $zendAuthAdapter->setCredentialTreatment("MD5(?) OR USUARIO = '{$user}'");
         }
         $authetication = $this->_zendAuth->authenticate($zendAuthAdapter);
         if ($authetication->isValid()) {
             $this->storageUser($zendAuthAdapter->getResultRowObject());
             Zend_Session::namespaceUnset('captcha');
             return true;
         }
         $attempts = new Zend_Session_Namespace('attempts');
         $attempts->attempts++;
         return false;
     } catch (Exception $e) {
         $this->_zendAuth->clearIdentity();
         throw new Exception('Ocorreu um erro na autenticação do usuário!' . $e->getMessage());
     }
 }
开发者ID:roquebrasilia,项目名称:sgdoc-codigo,代码行数:37,代码来源:Authentication.php

示例11: loginAction

 function loginAction()
 {
     $form = $this->getForm();
     if ($this->_request->isPost()) {
         $formData = $this->_request->getPost();
         if ($form->isValid($formData)) {
             $auth = Zend_Auth::getInstance();
             // Setup adapter
             $adapter = new Zend_Auth_Adapter_DbTable($this->_db, 'Extranet_Users', 'EU_Username', 'EU_Password', 'MD5(?)');
             $adapter->setIdentity($_POST['username'])->setCredential($_POST['password']);
             // Authenticate
             $result = $auth->authenticate($adapter);
             switch ($result->getCode()) {
                 case Zend_Auth_Result::FAILURE:
                 case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID:
                 case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND:
                 case Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS:
                     $error = Cible_Translation::getCibleText('error_auth_failure');
             }
             if (!$result->isValid()) {
                 $this->view->assign('error', $error);
             } else {
                 $auth->getStorage()->write($adapter->getResultRowObject(array('EU_ID', 'EU_LName', 'EU_FName', 'EU_Email')));
                 // build ACL rights
                 $data = (array) $auth->getStorage()->read();
                 $acl = Cible_FunctionsAdministrators::getACLUser($data['EU_ID']);
                 $defaultSession = new Zend_Session_Namespace();
                 $defaultSession->acl = $acl;
                 $this->_redirect($this->getRequest()->getParam('redirect'));
             }
         }
     }
     $this->view->assign('form', $form);
 }
开发者ID:anunay,项目名称:stentors,代码行数:34,代码来源:AuthController.php

示例12: login

 public static function login($login, $senha)
 {
     $dbAdapter = Zend_Db_Table::getDefaultAdapter('db');
     // Inicia o adaptador Zend_Auth para banco de dados
     $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
     $authAdapter->setTableName('users')->setIdentityColumn('login')->setCredentialColumn('password')->setCredentialTreatment('SHA1(?) AND active=1');
     // Define os dados para processar o login
     $authAdapter->setIdentity($login)->setCredential($senha);
     // Efetua o login
     $auth = Zend_Auth::getInstance();
     $result = $auth->authenticate($authAdapter);
     // Verifica se o login foi efetuado com sucesso
     if ($result->isValid()) {
         // Recupera o objeto do usuário, sem a senha
         $info = $authAdapter->getResultRowObject(null, 'password');
         $usuario = new Home_Model_User();
         $usuario->setUserId($info->id);
         $usuario->setName($info->name);
         $usuario->setLogin($info->login);
         $usuario->setRoleId($info->role);
         $storage = $auth->getStorage();
         $storage->write($usuario);
         return true;
     }
     throw new Exception('<div class="alert alert-danger">Nome de usu&aacute;rio ou senha inv&aacute;lida</div>');
 }
开发者ID:ezequielsp,项目名称:zf1,代码行数:26,代码来源:Auth.php

示例13: login

 public function login()
 {
     if ($this->_router->isPostRequest()) {
         if ($_POST['login'] != '' && $_POST['passwd'] != '') {
             $db = Zend_Db_Table::getDefaultAdapter();
             // tworzymy instancję adaptera autoryzacji
             $authAdapter = new Zend_Auth_Adapter_DbTable($db, 'cms_user', 'user_login', 'user_passwd');
             $authAdapter->setIdentity($_POST['login']);
             $authAdapter->setCredential(sha1($_POST['passwd']));
             // sprawdzamy, czy użytkownik jest aktywny
             $authAdapter->setCredentialTreatment("? AND user_active = '1'");
             // autoryzacja
             $result = $authAdapter->authenticate();
             if ($result->isValid()) {
                 $user_data = $authAdapter->getResultRowObject();
                 /*	zapisanie roli zalogowanego uzytkownika	*/
                 $this->_roles = RolesModel::Instance();
                 $role = $this->_roles->getRoleData($user_data->role_id);
                 $user_data->role_code = $role['role_code'];
                 $this->_storage->write($user_data);
                 // ustawienie ACL dla użytkownika
                 $this->_engine->addHttpHeader("Location: /" . $this->_router->getUrl('cms', 'index'));
             } else {
                 $this->_view->error = '1';
             }
         } else {
             $this->_view->error = '1';
         }
     }
     $this->_engine->setToRender('login.tpl');
 }
开发者ID:adammajchrzak,项目名称:silesiamaps,代码行数:31,代码来源:Controller.php

示例14: loginAction

 public function loginAction()
 {
     $request = $this->getRequest();
     $email = $request->getParam('email');
     $senha = md5($request->getParam('senha'));
     //$senha = ($request->getParam('senha'));
     if ($email != '' && $senha != '') {
         $auth = new Zend_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter());
         $auth->setIdentityColumn('email');
         $auth->setCredentialColumn('senha');
         $auth->setTableName('usuario');
         $auth->setIdentity($email);
         $auth->setCredential($senha);
         if (!Zend_Auth::getInstance()->authenticate($auth)->isValid()) {
             $this->_redirect('/admin');
         } else {
             $data = $auth->getResultRowObject(null);
             Zend_Auth::getInstance()->getStorage()->write($data);
             $identity = Zend_Auth::getInstance()->getIdentity();
             $this->_redirect('/admin');
         }
         /*} elseif($email == '' && $senha == ''){
         			$this->_redirect('/admin');
         		}
         		else {
         			$this->_redirect('/admin/solucao');
         		}*/
     } else {
         $this->_redirect('/admin/login');
     }
 }
开发者ID:robertsonmello,项目名称:projetos,代码行数:31,代码来源:LoginController.php

示例15: loginAction

 public function loginAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $storage = new Zend_Auth_Storage_Session();
         $storage->clear();
     }
     $users = new Application_Model_User();
     $form = new Application_Form_Login();
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             $data = $form->getValues();
             $auth = Zend_Auth::getInstance();
             $authAdapter = new Zend_Auth_Adapter_DbTable($users->getAdapter(), 'user');
             $authAdapter->setIdentityColumn('name')->setCredentialColumn('password');
             $authAdapter->setIdentity($data['name'])->setCredential($data['password']);
             $result = $auth->authenticate($authAdapter);
             if ($result->isValid()) {
                 $storage = new Zend_Auth_Storage_Session();
                 $storage->write($authAdapter->getResultRowObject(array('id', 'name', 'image')));
                 if ($auth->getIdentity()->name == 'admin') {
                     $this->redirect("Order/adminhome");
                 } elseif ($auth->getIdentity()->name != 'admin') {
                     $this->redirect("Order/adduserorder");
                 }
             } else {
                 $this->view->errorMessage = "Invalid username or password. Please try again.";
             }
         }
     }
 }
开发者ID:nguyenkiet,项目名称:cafeteria,代码行数:32,代码来源:AuthController.php


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