• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Zend_Auth_Adapter_DbTable类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了Zend_Auth_Adapter_DbTable类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


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


示例17: indexAction

 /**
  * IS: Parameter username, password, remember terdeklarasi
  * FS: Mengirimkan ke viewer: fail,
  *     Session berisi data userId dan username
  * Desc: Fungsi untuk login biasa
  */
 public function indexAction()
 {
     $this->_helper->viewRenderer->setNoRender(true);
     // Jika request ajax
     //if ($this->_request->isXmlHttpRequest()) {
     // Tidak menggunakan layout dan view
     $this->_helper->layout()->disableLayout();
     $loginForm = new Form_LoginForm();
     if ($this->getRequest()->isPost() and $loginForm->isValid($this->getRequest()->getPost())) {
         // Param
         $username = $this->_getParam('username');
         $password = $this->_getParam('password');
         $remember = $this->_getParam('remember');
         // Menggunakan auth adapter bawaan Zend
         $db = Zend_Db_Table::getDefaultAdapter();
         $authAdapter = new Zend_Auth_Adapter_DbTable($db, "user", 'username', 'password');
         // Set username dan password
         $authAdapter->setIdentity($username);
         $authAdapter->setCredential(md5($password));
         // Authentikasi
         $result = $authAdapter->authenticate();
         // Jika ada
         if ($result->isValid()) {
             // Menggunakan auth adapter bawaan Zend
             $db = Zend_Db_Table::getDefaultAdapter();
             $authAdapter = new Zend_Auth_Adapter_DbTable($db, "user", 'username', 'password', 'activationkey');
             // Set username dan password
             $authAdapter->setIdentity($username);
             $authAdapter->setCredential(md5($password));
             // Authentikasi
             $result = $authAdapter->authenticate();
             $auth = Zend_Auth::getInstance();
             $storage = $auth->getStorage();
             $storage->write($authAdapter->getResultRowObject(array('user_id', 'username', 'activationkey')));
             $identity = $auth->getIdentity();
             if ($this->_hasParam('remember')) {
                 $expire = time() + 1728000;
                 // 20 hari expired
                 $cookiePass = sha1(md5($password) . $identity->activationkey);
                 setcookie('budpar_userId', $identity->user_id, $expire, '/');
                 setcookie('budpar_user', $identity->username, $expire, '/');
                 setcookie('budpar_pass', $cookiePass, $expire, '/');
             }
             // Set Blacklist jika ada
             $this->_setBlacklist($identity->user_id);
             // Set nilai session
             $this->_sess->userId = $identity->user_id;
             $this->_sess->username = $identity->username;
             //echo 'success';
         } else {
             echo 'fail';
             $this->view->fail = true;
             $this->_sess->error = true;
         }
     } else {
         echo 'fail';
         $this->view->fail = true;
     }
     $this->_redirector->gotoUrl($this->_sess->previousUri);
 }
开发者ID:abdulhadikaryana,项目名称:kebudayaan,代码行数:66,代码来源:LoginController.php


示例18: validate

 /**
  * @return boolean
  */
 public function validate()
 {
     $this->actionController->oAcl->getStorage()->clear();
     if (!parent::validate()) {
         return false;
     }
     $sUserLogin = $this->controls['login']->getValue();
     $sUserPassword = $this->controls['password']->getValue();
     $oAuth = Zend_Auth::getInstance();
     $oAuthAdapter = new Zend_Auth_Adapter_DbTable();
     $oAuthAdapter->setTableName('user')->setIdentityColumn('login')->setCredentialColumn('password')->setCredentialTreatment('MD5(?)');
     $oAuthAdapter->setIdentity($sUserLogin)->setCredential($sUserPassword);
     $oSelect = $oAuthAdapter->getDbSelect();
     $oSelect->where('user.deleted = ?', 'no')->joinLeft('client', 'client.id = user.client', array('client_title' => 'client.title'));
     $oResult = $oAuth->authenticate($oAuthAdapter);
     if ($oResult->isValid()) {
         $aResult = (array) $oAuthAdapter->getResultRowObject();
         $aResult['role'] = $aResult['is_admin'] == 0 ? 'user' : 'admin';
         $oAuth->getStorage()->write($aResult);
         return true;
     } else {
         $this->errors[] = 'Invalid login or password';
         return false;
     }
 }
开发者ID:pansot2,项目名称:PadCMS-backend,代码行数:28,代码来源:Login.php


示例19: validate

 public static function validate($username, $hash, $rememberme = false)
 {
     if (!$username) {
         return false;
     }
     // TODO: try to make only one sql request
     $adapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $authAdapter = new Zend_Auth_Adapter_DbTable($adapter, 'users', 'pseudo', 'password');
     $authAdapter->setIdentity($username)->setCredential($hash);
     $auth = Zend_Auth::getInstance();
     $result = $auth->authenticate($authAdapter);
     if (!$result->isValid()) {
         self::$_current = null;
         return false;
     }
     $userid = $authAdapter->getResultRowObject('id')->id;
     $userMapper = new Syj_Model_UserMapper();
     $user = new Syj_Model_User();
     if (!$userMapper->find($userid, $user)) {
         throw new Zend_Exception();
     }
     $request = Zend_Controller_Front::getInstance()->getRequest();
     if (!$request->getCookie('syj_user') or !$request->getCookie('syj_hashpass')) {
         if ($rememberme) {
             // cookie will be valid for 2 weeks
             $time = time() + 14 * 60 * 24 * 60;
         } else {
             $time = 0;
         }
         setcookie("syj_user", $username, $time, "", "", false, true);
         setcookie("syj_hashpass", $hash, $time, "", "", false, true);
     }
     self::$_current = $user;
     return true;
 }
开发者ID:niavok,项目名称:syj,代码行数:35,代码来源:SyjUserManager.php


示例20: authAction

 public function authAction()
 {
     $request = $this->getRequest();
     $registry = Zend_Registry::getInstance();
     $auth = Zend_Auth::getInstance();
     $DB = $registry['DB'];
     $authAdapter = new Zend_Auth_Adapter_DbTable($DB);
     $authAdapter->setTableName('fitness_admin_accounts')->setIdentityColumn('admin_username')->setCredentialColumn('admin_password');
     // Set the input credential values
     $uname = $request->getParam('user_username');
     $paswd = $request->getParam('user_password');
     $authAdapter->setIdentity($uname);
     $authAdapter->setCredential(md5($paswd));
     // Perform the authentication query, saving the result
     $result = $auth->authenticate($authAdapter);
     if ($result->isValid()) {
         $data = $authAdapter->getResultRowObject(null, 'password');
         $auth->getStorage()->write($data);
         $sess = new Zend_Session_Namespace('AdminSession');
         if ($sess->isLocked()) {
             $sess->unlock();
         }
         $sess->username = $uname;
         $this->_redirect('/admin/homeuser');
     } else {
         $this->_redirect('/admin/index');
     }
 }
开发者ID:keyanmca,项目名称:yoga,代码行数:28,代码来源:AdminController.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Zend_Auth_Storage_Session类代码示例发布时间:2022-05-23
下一篇:
PHP Zend_Auth类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap