本文整理汇总了PHP中Zend_Auth_Adapter_DbTable::setTableName方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Auth_Adapter_DbTable::setTableName方法的具体用法?PHP Zend_Auth_Adapter_DbTable::setTableName怎么用?PHP Zend_Auth_Adapter_DbTable::setTableName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Auth_Adapter_DbTable
的用法示例。
在下文中一共展示了Zend_Auth_Adapter_DbTable::setTableName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
$this->auth = new Zend_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter());
$this->auth->setIdentityColumn('email');
$this->auth->setCredentialColumn('senha');
$this->auth->setTableName('usuario');
}
示例2: getAuthAdapter
/**
* Getter dell'adapter per l'autenticazione, opportunamente modificato per gestire la login del sito.
*
* @static
* @return Zend_Auth_Adapter_DbTable L'adapter per la login
*/
public static function getAuthAdapter()
{
if (!isset(self::$AuthAdapter)) {
self::$AuthAdapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter());
self::$AuthAdapter->setTableName('user')->setIdentityColumn('Email')->setCredentialColumn('Password')->setCredentialTreatment("SHA1(CONCAT(?, Salt)) AND Activated = '1'");
}
return self::$AuthAdapter;
}
示例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;
}
示例4: _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;
}
示例5: 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');
}
}
}
示例6: _getAuthAdapter
protected function _getAuthAdapter()
{
$dbAdapter = Zend_Db_Table::getDefaultAdapter();
$authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
$authAdapter->setTableName('users')->setIdentityColumn('username')->setCredentialColumn('password')->setCredentialTreatment('SHA1(CONCAT(?,salt))');
return $authAdapter;
}
示例7: 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;
}
示例8: 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;
}
示例9: 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ário ou senha inválida</div>');
}
示例10: 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');
}
}
示例11: Login
/**
* Login function authentication system
* @param Zend_Db_Table_Row $account
* @return boolean
*/
function Login(Zend_Db_Table_Row $account)
{
$select = $this->select()->where('email=?', $account->email)->limit(1);
$row = $this->fetchRow($select);
// set up the auth adapter
$db = Acl_Model_Account::getDefaultAdapter();
$authAdapter = new OS_Application_Adapter_Auth($account->email, $account->password);
$authAdapter = new Zend_Auth_Adapter_DbTable($db);
$authAdapter->setTableName($this->_name)->setIdentityColumn('email')->setCredentialColumn('password')->setCredentialTreatment('block = 0');
#->setCredentialTreatment('MD5(?) and block = 0');
$authAdapter->setIdentity($account->email);
$authAdapter->setCredential(crypt($account->password, $row->password));
$result = $authAdapter->authenticate();
Zend_Session::regenerateId();
if ($result->isValid()) {
$auth = Zend_Auth::getInstance();
$storage = $auth->getStorage();
$storage->write($authAdapter->getResultRowObject(array('id', 'email', 'registerdate', 'lastvisitdate', 'role_id', 'fullname', 'email_alternative')));
$account = $this->find($authAdapter->getResultRowObject()->id)->current();
#$account = $this->createRow( $account->toArray() );
$account->lastvisitdate = Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss');
$account->save();
return true;
}
return false;
}
示例12: indexAction
public function indexAction()
{
$form = new Application_Form_Login();
if ($this->getRequest()->isPost()) {
$data = $this->getRequest()->getPost();
if ($form->isValid($data)) {
$login = $form->getValue('login');
// <input name='login'>
$pass = md5($form->getValue('pass'));
$adaptateur = new Zend_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter());
$adaptateur->setTableName('membre')->setIdentityColumn('login')->setCredentialColumn('pass')->setIdentity($login)->setCredential($pass);
if ($adaptateur->authenticate()->isValid()) {
// BRAVO
$storage = Zend_Auth::getInstance()->getStorage();
$mapper = new Application_Model_Mapper_Membre();
$membre = $mapper->getByLogin($login);
$storage->write($membre);
$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/auth.ini');
$controller = $config->auth->defaultController;
$action = $config->auth->defaultAction;
$this->_helper->getHelper('Redirector')->gotoSimple($action, $controller);
} else {
$this->view->msgErreur = "Mauvais login/pass";
$form->populate($data);
}
} else {
$form->populate($data);
$form->buildBootstrapErrorDecorators();
$this->view->msgErreur = "Veuillez vérifier votre formulaire !";
}
}
$this->view->form = $form;
}
示例13: 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!");
}
}
}
}
示例14: loginAction
public function loginAction()
{
$auth = Zend_Auth::getInstance();
$request = $this->getRequest();
$form = new Form_User_Login();
if ($this->getRequest()->isPost()) {
if ($form->isValid($request->getPost())) {
$bootstrap = $this->getInvokeArg('bootstrap');
$resource = $bootstrap->getPluginResource('db');
$dbAdapter = $resource->getDbAdapter();
$authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
$authAdapter->setTableName('users')->setIdentityColumn('email')->setCredentialColumn('password')->setIdentity($form->getValue('email'))->setCredential(hash('ripemd160', $form->getValue('password')));
$authResult = $auth->authenticate($authAdapter);
if ($authResult->isValid()) {
//$auth->getStorage()->write($adapter->getResultRowObject());
$userId = $authAdapter->getResultRowObject('id');
$user = new Model_User();
$user = $user->find($userId);
$globalSession = Zend_Registry::get('dlo.session');
$globalSession->user = $user;
return $this->_helper->redirector('index');
} else {
$email = $form->getElement('email');
$email->addError("Sorry either entered email or password is incorrect.");
}
}
}
$this->view->form = $form;
}
示例15: 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());
}
}