當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Auth_Adapter_DbTable類代碼示例

本文整理匯總了PHP中Zend_Auth_Adapter_DbTable的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Auth_Adapter_DbTable類的具體用法?PHP Zend_Auth_Adapter_DbTable怎麽用?PHP Zend_Auth_Adapter_DbTable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Zend_Auth_Adapter_DbTable類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例2: _getAuthAdapter

 protected function _getAuthAdapter()
 {
     $admins = new Application_Model_DbTable_Admins();
     $authAdapter = new Zend_Auth_Adapter_DbTable($admins->getAdapter());
     $authAdapter->setTableName('admins')->setIdentityColumn('admin_username')->setCredentialColumn('hashed_password')->setCredentialTreatment('SHA1(?)');
     return $authAdapter;
 }
開發者ID:ankuradhey,項目名稱:laundry,代碼行數:7,代碼來源:AuthController.php

示例3: login

 public static function login($login, $senha)
 {
     $dbAdapter = Zend_Db_Table::getDefaultAdapter();
     //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(?)');
     //Define os dados para processar o login
     $authAdapter->setIdentity($login)->setCredential($senha);
     //Faz inner join dos dados do perfil no SELECT do Auth_Adapter
     $select = $authAdapter->getDbSelect();
     $select->join('roles', 'roles.id_role = users.id_role', array('role_roles' => 'role', 'id_role'));
     //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 Application_Model_Users();
         $usuario->setFullName($info->nome);
         $usuario->setUserName($info->login);
         $usuario->setRoleId($info->role_roles);
         $usuario->setRoleCod($info->id_role);
         $storage = $auth->getStorage();
         $storage->write($usuario);
         return true;
     }
     throw new Exception('Nome de usuário ou senha inválida');
 }
開發者ID:rossanorb,項目名稱:zend_acl,代碼行數:29,代碼來源:Auth.php

示例4: 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

示例5: indexAction

 public function indexAction()
 {
     $storage = new Zend_Auth_Storage_Session('admin_type');
     $data = $storage->read();
     if ($data && $data != null) {
         $this->_redirect('admin/');
     }
     $this->view->messages = $this->_flashMessenger->getMessages();
     //$this->_helper->layout()->disableLayout();
     $this->_helper->layout()->setLayout('adminlogin');
     $users = new Admin_Model_DbTable_AdminUsers();
     if ($this->getRequest()->isPost()) {
         $formdata = $this->getRequest()->getPost();
         $enc_pwd = md5($formdata['user_password']);
         //print_r($formdata);exit;
         $auth = Zend_Auth::getInstance();
         $authAdapter = new Zend_Auth_Adapter_DbTable($users->getAdapter(), TBL_ADMIN);
         $authAdapter->setIdentityColumn('user_name')->setCredentialColumn('user_password');
         $authAdapter->setIdentity($formdata['user_name'])->setCredential($enc_pwd);
         $result = $auth->authenticate($authAdapter);
         if ($result->isValid()) {
             $storage = new Zend_Auth_Storage_Session('admin_type');
             $storage->write($authAdapter->getResultRowObject());
             $this->_redirect('admin/');
         } else {
             $this->view->errorMessage = '<div class="div-error">Invalid username or password</div>';
         }
     }
 }
開發者ID:vmangla,項目名稱:evendor,代碼行數:29,代碼來源:AuthController.php

示例6: _getAuthAdapter

 protected function _getAuthAdapter()
 {
     $dbAdapter = Zend_Db_Table::getDefaultAdapter();
     $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
     $authAdapter->setTableName('school_staff')->setIdentityColumn('email')->setCredentialColumn('password')->setCredentialTreatment('md5(?)');
     return $authAdapter;
 }
開發者ID:namastePrashant,項目名稱:cms,代碼行數:7,代碼來源:LoginController.php

示例7: loginAction

 public function loginAction()
 {
     $formLogin = new Form_Admin_Login();
     $formLogin->submit->setLabel("Logar");
     $this->view->form = $formLogin;
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         if ($formLogin->isValid($data)) {
             $email = $formLogin->getValue('administrador_email');
             $senha = $formLogin->getValue('administrador_senha');
             $db = Zend_Registry::get('db');
             $authAdapter = new Zend_Auth_Adapter_DbTable($db);
             $authAdapter->setTableName('administrador')->setIdentityColumn('administrador_email')->setCredentialColumn('administrador_senha')->setIdentity($email)->setCredential(md5($senha));
             $authAdapter->getDbSelect()->where("administrador_ativo = ?", 1);
             $auth = Zend_Auth::getInstance();
             $result = $auth->authenticate($authAdapter);
             if ($result->isValid()) {
                 $modelAdministrador = new Model_DbTable_Administrador();
                 $administrador = $modelAdministrador->getByField("administrador_email", $email);
                 Zend_Auth::getInstance()->getStorage()->write($administrador);
                 $this->_redirect("admin/");
             } else {
                 $this->_helper->flashMessenger->addMessage(array('danger' => 'Usuário e/ou senha inválidos'));
             }
         }
     }
 }
開發者ID:nandorodpires2,項目名稱:homemakes,代碼行數:27,代碼來源:AuthController.php

示例8: indexAction

 /**
  * Авторизация 
  */
 public function indexAction()
 {
     // вывод загаловков
     $this->view->title = "Авторизация";
     $this->view->headTitle($this->view->title, 'PREPEND');
     // форма
     $form = new Application_Form_Auth();
     $message = '';
     if ($this->_request->isPost()) {
         $formData = $this->_request->getPost();
         if ($form->isValid($formData)) {
             $auth = Zend_Auth::getInstance();
             $authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter(), 'users', 'login', 'password');
             $data = $form->getValues();
             $authAdapter->setIdentity($data['login'])->setCredential($data['password']);
             $result = $auth->authenticate($authAdapter);
             if ($result->isValid()) {
                 $currentUser = $authAdapter->getResultRowObject(array('id_user', 'login', 'role'));
                 Zend_Auth::getInstance()->getStorage()->write($currentUser);
                 $this->_redirect($data['redirect']);
             } else {
                 $message = 'Попробуйте еще раз.';
             }
         }
     }
     // вывод в шаблон
     $this->view->message = $message;
     $this->view->form = $form;
 }
開發者ID:MichaelGogeshvili,項目名稱:strap,代碼行數:32,代碼來源:AuthController.php

示例9: indexAction

 public function indexAction()
 {
     $form = new Login_Form();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             $authAdapter = new Zend_Auth_Adapter_DbTable();
             $authAdapter->setTableName("employees")->setIdentityColumn("login")->setCredentialColumn("password")->setCredentialTreatment("SHA1(CONCAT(?, salt)) && (active = 1 || super_admin = 1)")->setIdentity($form->getValue("login"))->setCredential($form->getValue("password"));
             $auth = Zend_Auth::getInstance();
             if ($auth->authenticate($authAdapter)->isValid()) {
                 $authStorage = $auth->getStorage();
                 $employee = $authAdapter->getResultRowObject();
                 $authStorage->write($employee);
                 $db = Zend_Db_Table::getDefaultAdapter();
                 $data = array("last_login" => date("Y-m-d H:i:s"));
                 $db->update('employees', $data, "employee_id =" . $employee->employee_id);
                 $session = new Zend_Session_Namespace(\Application\Controller\Plugin\Auth::SESSION_NAMESPACE);
                 $uri = $session->referer;
                 if ($uri == "/" || $uri == "/login" || $uri == "/logout") {
                     $this->getHelper("redirector")->gotoSimple("index", "index");
                 } else {
                     $this->getHelper("redirector")->gotoUrl($uri);
                 }
             } else {
                 $this->view->formErrors = array("Niepoprawny login lub hasło");
                 $this->view->data = $form->getUnfilteredValues();
             }
         } else {
             $this->view->formErrors = $form->getMessages();
             $this->view->data = $form->getUnfilteredValues();
         }
     }
 }
開發者ID:sp1ke77,項目名稱:MLM-1,代碼行數:32,代碼來源:LoginController.php

示例10: getAuthAdapter

 /**
  * Gets the adapter for authentication against a database table
  *
  * @return object
  */
 public static function getAuthAdapter()
 {
     $dbAdapter = Zend_Db_Table::getDefaultAdapter();
     $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
     $authAdapter->setTableName('cc_subjs')->setIdentityColumn('login')->setCredentialColumn('pass')->setCredentialTreatment('MD5(?)');
     return $authAdapter;
 }
開發者ID:RadioCampusFrance,項目名稱:airtime,代碼行數:12,代碼來源:Auth.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: loginAction

 public function loginAction()
 {
     //$this->_helper->layout()->disableLayout();
     $formAuthLogin = new Form_Auth_Login();
     $this->view->form = $formAuthLogin;
     if ($this->getRequest()->isPost()) {
         if ($formAuthLogin->isValid($this->getRequest()->getPost())) {
             $dadosAutenticacao = $formAuthLogin->getValues();
             $db = Zend_Registry::get('db');
             $authAdapter = new Zend_Auth_Adapter_DbTable($db);
             try {
                 $authAdapter->setTableName('administrador')->setIdentityColumn('administrador_email')->setCredentialColumn('administrador_senha')->setIdentity($dadosAutenticacao['administrador_email'])->setCredential(md5($dadosAutenticacao['administrador_senha']));
                 $authAdapter->getDbSelect()->where("administrador_ativo = ?", 1);
                 $auth = Zend_Auth::getInstance();
                 $result = $auth->authenticate($authAdapter);
                 if ($result->isValid()) {
                     $dadosAdministrador = array();
                     Zend_Auth::getInstance()->getStorage()->write($dadosAdministrador);
                     $this->_redirect("index/");
                 } else {
                     $this->_helper->flashMessenger->addMessage(array('class' => 'alert alert-danger', 'message' => 'Usuário e/ou senha inválidos!'));
                     Zend_Debug::dump($result);
                     die;
                     $this->_redirect("admin/autenticacao/login");
                 }
             } catch (Exception $e) {
                 $this->_helper->flashMessenger->addMessage(array('class' => 'alert alert-danger', 'message' => 'Houve um erro na autenticação - ' . $e->getMessage()));
                 $this->_redirect("auth/login");
             }
         }
     }
 }
開發者ID:nandorodpires2,項目名稱:k-sys,代碼行數:32,代碼來源:AuthController.php

示例13: 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

示例14: getAuthAdapter

 public function getAuthAdapter()
 {
     //$authAdapter = new Zend_Auth_Adapter_DbTable ( Zend_Db_Table::getDefaultAdapter () );
     $authAdapter = new Zend_Auth_Adapter_DbTable($this->db);
     $authAdapter->setTableName('employe')->setIdentityColumn('username')->setCredentialColumn('password');
     return $authAdapter;
 }
開發者ID:razorcell,項目名稱:GBADMIN,代碼行數:7,代碼來源:AuthenticationController.php

示例15: loginAction

 public function loginAction()
 {
     $this->view->pagina_action = "Login";
     $this->view->pagina_descricao = "Informe seu usuário e senha para acessar o sistema.";
     // Instancia o formulário de login
     $objFormLogin = new Default_Form_Login();
     if ($this->_request->isPost()) {
         $data = $this->getRequest()->getPost();
         if ($objFormLogin->isValid($data)) {
             $objAuth = Zend_Auth::getInstance();
             $authAdapter = new Zend_Auth_Adapter_DbTable(Lepard_Db_Adapter::get(), 'usuario', 'login', 'password');
             $authAdapter->setIdentity($data['login'])->setCredential($data['password']);
             //print_r($authAdapter);die;
             $result = $objAuth->authenticate($authAdapter);
             if ($result->isValid()) {
                 /**
                  * Pega os dados do usuário, omitindo a senha
                  * http://framework.zend.com/manual/en/zend.auth.adapter.dbtable.html
                  */
                 $authData = $authAdapter->getResultRowObject(null, 'password');
                 // Armazena os dados do usuário
                 $objAuth->getStorage()->write($authData);
                 echo 'Login efetuado com sucesso!';
                 $this->getHelper('Redirector')->setGotoUrl('/index');
             } else {
                 echo 'Os dados informados (login/senha) não são válidos.';
             }
         }
     }
     $this->view->form = $objFormLogin;
 }
開發者ID:mayconheerdt,項目名稱:zfSkeleton,代碼行數:31,代碼來源:IndexController.php


注:本文中的Zend_Auth_Adapter_DbTable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。