本文整理汇总了PHP中Zend_Auth_Adapter_DbTable::getDbSelect方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Auth_Adapter_DbTable::getDbSelect方法的具体用法?PHP Zend_Auth_Adapter_DbTable::getDbSelect怎么用?PHP Zend_Auth_Adapter_DbTable::getDbSelect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Auth_Adapter_DbTable
的用法示例。
在下文中一共展示了Zend_Auth_Adapter_DbTable::getDbSelect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loginAction
public function loginAction()
{
$formAdminLogin = new Form_Admin_Login();
$this->view->formAdminLogin = $formAdminLogin;
if ($this->getRequest()->isPost()) {
$data = $this->getRequest()->getPost();
if ($formAdminLogin->isValid($data)) {
$email = $formAdminLogin->getValue('administrador_email');
$senha = $formAdminLogin->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->getCredentials($email, $senha);
Zend_Auth::getInstance()->getStorage()->write($administrador);
$this->_redirect("/admin");
} else {
die("Dados incorretos!");
}
}
}
}
示例2: 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");
}
}
}
}
示例3: 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'));
}
}
}
}
示例4: authenticate
public static function authenticate(array $values)
{
$email = isset($values['email']) ? $values['email'] : null;
$senha = isset($values['senha']) ? $values['senha'] : null;
if (!count($values)) {
throw new Exception('Não foi passado valores para autenticar');
}
// Pegar os dados da autenticacao e checa
$dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
$authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
$authAdapter->setTableName('usuario')->setIdentityColumn('email')->setCredentialColumn('senha');
$authAdapter->setIdentity($email)->setCredential($senha)->setCredentialTreatment('MD5(?)');
$select = $authAdapter->getDbSelect();
$select->join(array('g' => 'grupo'), 'g.id = usuario.grupo_id', array('grupo' => 'nome'));
//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
return true;
}
return false;
}
示例5: auth
public function auth($usuario, $password)
{
$dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
$authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
$authAdapter->setTableName('cn_admin')->setIdentityColumn('email')->setCredentialColumn('password')->setIdentity($usuario)->setCredential(md5($password));
$select = $authAdapter->getDbSelect();
$select->where('flagactive = 1');
$result = Zend_Auth::getInstance()->authenticate($authAdapter);
if ($result->isValid()) {
$storage = Zend_Auth::getInstance()->getStorage();
$bddResultRow = $authAdapter->getResultRowObject();
$storage->write($bddResultRow);
$msj = 'Bienvenido Usuario ' . $result->getIdentity();
$this->view->message = $this->_flashMessenger->success($msj);
$this->_identity = Zend_Auth::getInstance()->getIdentity();
$return = true;
} else {
switch ($result->getCode()) {
case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND:
$msj = 'El usuario no existe';
break;
case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID:
$msj = 'Password incorrecto';
break;
default:
$msj = 'Datos incorrectos';
break;
}
$this->view->message = $this->_flashMessenger->warning($msj);
$return = false;
}
return $return;
}
示例6: loginAction
public function loginAction()
{
$this->_form = new Mybase_Form_Login();
if (!$this->getRequest()->isPost()) {
$this->view->form = $this->_form;
} else {
$form = $this->_form;
if (!$form->isValid($_POST)) {
$this->view->form = $form;
$this->_flash('Všechna pole musí být vyplněna', 'error', false);
} else {
$values = $form->getValues();
$auth = Zend_Auth::getInstance();
$authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table_Abstract::getDefaultAdapter(), 'user_login', 'username', 'password', 'MD5(?)');
$modelAccount = new Model_Account();
$idaccount = $modelAccount->getId($this->_request->account);
$select = $authAdapter->getDbSelect();
$select->where('idaccount = ' . $idaccount);
$authAdapter->setIdentity($values['username']);
$authAdapter->setCredential($values['password']);
$result = $auth->authenticate($authAdapter);
switch ($result->getCode()) {
case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND:
$this->view->form = $form;
$this->_flash('Špatné uživatelské jméno', 'error', false);
break;
case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID:
$this->view->form = $form;
$this->_flash('Špatné heslo', 'error', false);
break;
case Zend_Auth_Result::SUCCESS:
$storage = $auth->getStorage();
$storage->write($authAdapter->getResultRowObject(array('email', 'name', 'surname', 'username', 'iduser', 'owner', 'administrator')));
if ($form->getValue('remember') == 1) {
Zend_Session::rememberMe(60 * 60 * 24 * 14);
}
//$this->_redirect('http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);
$this->_redirect('/');
break;
case Zend_Auth_Result::FAILURE:
$this->view->form = $form;
$this->_flash('Neznámá chyba (FAILURE)', 'error', false);
break;
case Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS:
$this->view->form = $form;
$this->_flash('"Nejednoznačné"', 'error', false);
break;
case Zend_Auth_Result::FAILURE_UNCATEGORIZED:
$this->view->form = $form;
$this->_flash('Neznámá chyba(FAILURE_UNCATEGORIZED)', 'error', false);
break;
default:
$this->view->form = $form;
$this->_flash('Neznámá chyba (default)', 'error', false);
break;
}
}
}
$this->_helper->layout->disableLayout();
}
示例7: loginAction
public function loginAction()
{
// // set template login
$template_path = TEMPLATE_PATH . "/default/before";
$this->loadTemplate($template_path, 'template.ini', 'default');
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) {
$this->_redirect(HOST_PATH_PUBLIC);
}
if ($this->_request->isPost()) {
$authTable = new Zend_Auth_Adapter_DbTable();
// tao adapter
$authTable->setTableName('user')->setIdentityColumn('email')->setCredentialColumn('password');
//cot du lieu 2
$fname = $this->_request->getPost('email');
$fpass = $this->_request->getPost('password');
$fpass = md5($fpass);
$authTable->setIdentity($fname)->setCredential($fpass);
$authTable->getDbSelect();
$auth = Zend_Auth::getInstance();
$kq = $auth->authenticate($authTable);
if ($kq->isValid()) {
$user = $authTable->getResultRowObject(null, array("password"));
$auth->getStorage()->write($user);
$this->_redirect(HOST_PATH_PUBLIC);
} else {
$this->_redirect(HOST_PATH_PUBLIC . '/index/login');
}
}
}
示例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;
}
示例9: 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');
}
示例10: login
public function login($arrParam, $options = null)
{
//1. Goi ket noi voi Zend Db
$db = Zend_Registry::get('connectDb');
//2.Khoi tao Zend Auth
$auth = Zend_Auth::getInstance();
//3
$authAdapter = new Zend_Auth_Adapter_DbTable($db);
//Zend_Db_Adapter_Abstract $zendDb = null, $tableName = null, $identityColumn = null,
// $credentialColumn = null, $credentialTreatment = null)
$authAdapter->setTableName('da_users')->setIdentityColumn('user_name')->setCredentialColumn('password');
$select = $authAdapter->getDbSelect();
$select->where('status = 1');
$encode = new Zendda_Encode();
$user_name = $arrParam['user_name'];
$password = $encode->password($arrParam['password']);
$authAdapter->setIdentity($user_name);
$authAdapter->setCredential($password);
//Lay ket qua truy van cua Zend_Auth
$result = $auth->authenticate($authAdapter);
$flag = false;
if (!$result->isValid()) {
$error = $result->getMessages();
$this->_messageError = current($error);
} else {
$omitColumns = array('password');
$data = $authAdapter->getResultRowObject(null, $omitColumns);
$auth->getStorage()->write($data);
$flag = true;
}
return $flag;
}
示例11: 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;
}
}
示例12: indexAction
public function indexAction()
{
if (!empty($this->sessPublisherInfo)) {
$this->_redirect('publisher/');
}
//$this->_helper->layout()->setLayout('publisherlogin');
$this->view->messages = $this->_flashMessenger->getMessages();
$formData = array();
$formErrors = array();
if ($this->getRequest()->isPost()) {
$formData = $this->getRequest()->getPost();
//print_r($formData);exit;
if (!isset($formData['user_name']) || trim($formData['user_name']) == "") {
$formErrors['user_name'] = "Please enter your username";
}
if (!isset($formData['user_password']) || trim($formData['user_password']) == "") {
$formErrors['user_password'] = "Please enter your password";
}
if (count($formErrors) == 0) {
$usermailID = trim($formData['user_name']);
$getLoginRecord = $this->modelPublishers->getInfoByLoginEmail($usermailID);
if (count($getLoginRecord) > 0) {
for ($countUser = 0; $countUser < count($getLoginRecord); $countUser++) {
if ($getLoginRecord[$countUser]['user_type'] != 'author') {
$auth = Zend_Auth::getInstance();
$authAdapter = new Zend_Auth_Adapter_DbTable($this->modelPublishers->getAdapter(), TBL_PUBLISHERS);
$authAdapter->setIdentityColumn('emailid')->setCredentialColumn('password');
$authAdapter->setIdentity($formData['user_name'])->setCredential(md5($formData['user_password']));
$authAdapter->getDbSelect()->where('user_type="' . $getLoginRecord[$countUser]['user_type'] . '"');
$result = $auth->authenticate($authAdapter);
if ($result->isValid()) {
$userInfo = $authAdapter->getResultRowObject();
if ($this->modelPublishers->isExist('profile_status=1 AND id=' . $userInfo->id)) {
$storage = new Zend_Auth_Storage_Session('publisher_type');
$storage->write($userInfo);
$this->_redirect('publisher/');
} else {
$this->view->errorMessage = '<div class="div-error">Sorry, user is not active</div>';
}
} else {
$this->view->errorMessage = '<div class="div-error">Invalid username or password</div>';
}
}
}
} else {
$this->view->errorMessage = '<div class="div-error">Invalid username or password</div>';
}
} else {
$this->view->errorMessage = '<div class="div-error">Please enter username and password</div>';
}
}
$sessionMsg = new Zend_Session_Namespace('step1Msg');
$sessionMsg->formData = $formData;
$sessionMsg->formErrors = $formErrors;
$sessionMsg->errorMessage = $this->view->errorMessage;
//$this->_redirect('/');
}
示例13: _getAuthAdapter
/**
* This function returns an auth adapter for the login systems
*
* @param array params
* @return Zend_Auth_Adapter_DbTable
*
* This function takes a params array (which should be login form values)
* and creates a zend auth adapter linked to the correct database
* and users table. If the params array has come from a login form and has
* a username and password fields it will set them as the identity
* and credentials in the auth adapter so that we can check to see if they
* are valid
*/
protected function _getAuthAdapter(array $params)
{
$authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Registry::get('db_legacy_homelet'));
$authAdapter->setTableName('agentid')->setIdentityColumn('username')->setCredentialColumn('password')->setCredentialTreatment("?");
$authAdapter->setIdentity($params['username']);
$authAdapter->setCredential($params['password']);
$dbselect = $authAdapter->getDbSelect();
// Link against the agent scheme number
$dbselect->where('agentschemeno = ?', array($params['agentschemeno']));
return $authAdapter;
}
示例14: testAdapterReturnsASelectObjectWithoutAuthTimeModificationsAfterAuth
/**
* @group ZF-5957
*/
public function testAdapterReturnsASelectObjectWithoutAuthTimeModificationsAfterAuth()
{
$select = $this->_adapter->getDbSelect();
$select->where('1 = 1');
$this->_adapter->setIdentity('my_username');
$this->_adapter->setCredential('my_password');
$this->_adapter->authenticate();
$selectAfterAuth = $this->_adapter->getDbSelect();
$whereParts = $selectAfterAuth->getPart(Zend_Db_Select::WHERE);
$this->assertEquals(1, count($whereParts));
$this->assertEquals('(1 = 1)', array_pop($whereParts));
}
示例15: auth
public function auth($usuario, $password, $url = null)
{
$dbAdapter = Zend_Registry::get('multidb');
$authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
// $hash = password_hash($password, PASSWORD_DEFAULT);
$authAdapter->setTableName('tusers')->setIdentityColumn('login')->setCredentialColumn('password')->setIdentity($usuario)->setCredential($password);
try {
$select = $authAdapter->getDbSelect();
$select->where('state = 1');
$result = Zend_Auth::getInstance()->authenticate($authAdapter);
if ($result->isValid()) {
$storage = Zend_Auth::getInstance()->getStorage();
$bddResultRow = $authAdapter->getResultRowObject();
$storage->write($bddResultRow);
$msj = 'Bienvenido Usuario ' . $result->getIdentity();
$this->_identity = Zend_Auth::getInstance()->getIdentity();
if (isset($mysession->destination_url)) {
$url = $mysession->destination_url;
unset($mysession->destination_url);
$this->_redirect($url);
}
if (!empty($url)) {
$this->_redirect($url);
}
$return = true;
} else {
switch ($result->getCode()) {
case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND:
$msj = 'El usuario no existe';
break;
case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID:
$msj = 'Password incorrecto';
break;
case Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS:
$msj = 'Identidad Ambigua';
break;
case Zend_Auth_Result::FAILURE_UNCATEGORIZED:
$msj = 'Credencial Fracasada';
break;
default:
$msj = 'Datos incorrectos';
break;
}
$this->_flashMessenger->warning($msj);
$return = false;
}
} catch (Exception $e) {
echo $e->getMessage();
exit;
}
return $return;
}