本文整理汇总了PHP中Zend_Auth_Adapter_DbTable::setCredential方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Auth_Adapter_DbTable::setCredential方法的具体用法?PHP Zend_Auth_Adapter_DbTable::setCredential怎么用?PHP Zend_Auth_Adapter_DbTable::setCredential使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Auth_Adapter_DbTable
的用法示例。
在下文中一共展示了Zend_Auth_Adapter_DbTable::setCredential方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: login
public function login($username, $password)
{
$ret = false;
$filter = new Zend_Filter_StripTags();
$username = $filter->filter($username);
$password = $filter->filter($password);
if (isset($username) && isset($password)) {
$db = Das_Db::factory();
$authAdapter = new Zend_Auth_Adapter_DbTable($db);
$authAdapter->setTableName('v9_user');
$authAdapter->setIdentityColumn('username');
$authAdapter->setCredentialColumn('password');
$authAdapter->setIdentity($username);
$authAdapter->setCredential($password);
$result = $this->auth->authenticate($authAdapter);
if ($result->isValid()) {
$storage = $this->auth->getStorage();
// $retObj = $authAdapter->getResultRowObject();
// $storage->write($retObj->group_id);
$storage->write($authAdapter->getResultRowObject());
$ret = true;
}
}
return $ret;
}
示例3: authAction
public function authAction()
{
if ($this->getRequest()->isPost()) {
$form = new Application_Form_Login();
$this->view->form = $form;
$formData = $this->_request->getPost();
if (!strlen($formData['username']) || !strlen($formData['password'])) {
$this->_redirect('/login');
return false;
}
$request = $this->getRequest();
$registry = Zend_Registry::getInstance();
$auth = Zend_Auth::getInstance();
$DB = $registry['DB'];
$authAdapter = new Zend_Auth_Adapter_DbTable($DB);
$authAdapter->setTableName('users')->setIdentityColumn('username')->setCredentialColumn('password');
// Set the input credential values
$uname = $request->getParam('username');
$paswd = $request->getParam('password');
$authAdapter->setIdentity($uname);
$authAdapter->setCredential($paswd);
// Perform the authentication query, saving the result
$result = $auth->authenticate($authAdapter);
$data = $authAdapter->getResultRowObject(null, 'password');
if ($result->isValid()) {
$auth->getStorage()->write($data);
$this->_helper->redirector('welcome', 'Login');
} else {
$this->_redirect('/login');
}
}
}
示例4: indexAction
public function indexAction()
{
$form = new App_Painel_Form_Login();
$request = $this->getRequest();
if ($request->isPost()) {
if ($form->isValid($request->getPost())) {
$data = $request->getPost();
$adapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter());
$adapter->setTableName("usuario");
$adapter->setIdentityColumn("nm_email");
$adapter->setCredentialColumn("co_senha");
$adapter->setIdentity($data["usuario"]);
$adapter->setCredential($data["senha"]);
$adapter->setCredentialTreatment("MD5(?)");
$result = $this->auth->authenticate($adapter);
if ($result->isValid()) {
$dados = $adapter->getResultRowObject(null, "co_senha");
$dados->sessao = "admin";
$this->auth->getStorage()->write($dados);
$this->_redirect("/painel");
} else {
$this->view->error = "Email ou Senha incorreto";
}
}
}
$this->view->form = $form;
}
示例5: indexAction
public function indexAction()
{
$form = $this->_getLoginForm();
if (!$this->getRequest()->isPost() || !$form->isValid($_POST)) {
$this->view->loginForm = $form;
return;
}
$val = $form->getValues();
$adapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter());
$adapter->setTableName('User');
$adapter->setIdentityColumn('username');
$adapter->setCredentialColumn('password');
$adapter->setIdentity($val['username']);
$adapter->setCredential(sha1($val['password']));
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate($adapter);
if ($result->isValid()) {
// Do not store password for security purposes
$auth->getStorage()->write($adapter->getResultRowObject(null, 'password'));
$this->_helper->redirector('index', 'index');
} else {
$this->view->failed = true;
$this->view->loginForm = $form;
}
}
示例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: 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;
}
示例8: login
/**
* Preform a login authentication attempt. Includes basic brute forcing protection.
*/
public function login($login, $pass)
{
if ($login == '' || $pass == '') {
$result = false;
} else {
$protection = new Brute();
if ($protection->testIp()) {
$salt = Zend_Registry::get('salt');
//table users field user, password hashed with given function
$adapter = new Zend_Auth_Adapter_DbTable($this->_db, 'users', 'user', 'password', 'SHA1( CONCAT( ?, "' . $salt . '", salt ) ) AND active=1');
$adapter->setIdentity($login);
$adapter->setCredential($pass);
$result = $this->_auth->authenticate($adapter);
if ($result->isValid()) {
$storage = $this->_auth->getStorage();
$storage->write($adapter->getResultRowObject(array('uid', 'user', 'name', 'email')));
$this->_storage->path->fromUid($this->_auth->getIdentity()->uid);
$this->_storage->storeAll();
$result = self::OK;
} else {
$protection->registerBad();
$result = self::BAD;
}
} else {
//the protection has locked this IP address
$result = self::BLOCK;
}
}
return $result;
}
示例9: loginAction
function loginAction()
{
require_once 'login.php';
$form = new forms_login();
if (!$this->getRequest()->isPost()) {
$this->view->loginForm = $form;
return;
}
$values = array('username' => $_POST['username'], 'password' => $_POST['password']);
// Setup DbTable adapter
$adapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter());
// set earlier in Bootstrap
$adapter->setTableName('sis_users');
$adapter->setIdentityColumn('CAUS_TX_Usuario');
$adapter->setCredentialColumn('CAUS_TX_Senha');
$adapter->setIdentity($values['username']);
$adapter->setCredential($values['password']);
// authentication attempt
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate($adapter);
// authentication succeeded
if ($result->isValid()) {
$data = $adapter->getResultRowObject(null, 'password');
$auth->getStorage()->write($data);
$_SESSION['userid'] = $data->CAUS_NM_ID;
return $this->_redirect('system/system');
} else {
// or not! Back to the login page!
$this->view->failedAuthentication = true;
$this->view->form = $form;
}
}
示例10: loginAction
public function loginAction()
{
$userForm = new Form_LoginForm();
$userForm->setAction('/auth/login');
if ($this->_request->isPost() && $userForm->isValid($_POST)) {
$data = $userForm->getValues();
$db = Zend_Db_Table::getDefaultAdapter();
$authAdapter = new Zend_Auth_Adapter_DbTable($db, 'utils', 'username', 'source');
$authAdapter->setIdentity($data['username']);
$authAdapter->setCredential($data['password']);
$result = $authAdapter->authenticate();
if ($result->isValid()) {
$auth = Zend_Auth::getInstance();
$data1 = $authAdapter->getResultRowObject(null, 'source');
// $auth->getStorage()->write($data1);
// $auth->getStorage()->write($data);
$dom = $auth->getIdentity()->domainadmin;
$host = $auth->getIdentity()->hostadmin;
$mySession = SessionWrapper::getInstance();
$mySession->setSessVar('username', $formData['username']);
date_default_timezone_set('Europe/Brussels');
echo 'valid';
} else {
$this->view->loginMessage = "Sorry, your username or password was incorrect";
}
}
$this->view->form = $userForm;
}
示例11: indexAction
public function indexAction()
{
$form = new Application_Form_Login();
$form->setAction('/auth');
if ($this->_request->isPost()) {
$formData = $this->_request->getPost();
if ($form->isValid($formData)) {
$auth = Zend_Auth::getInstance();
$db = Zend_Registry::get('db');
$authAdapter = new Zend_Auth_Adapter_DbTable($db, 'users', 'username', 'password');
$authAdapter->setIdentity($formData['username']);
$authAdapter->setCredential($formData['password']);
$result = $authAdapter->authenticate();
$session = Zend_Registry::get('session');
switch ($result->getCode()) {
case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID:
$session->erro = 'senha';
$form->populate($formData);
break;
case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND:
$session->erro = 'Usuario Inválido';
$form->populate($formData);
break;
case Zend_Auth_Result::SUCCESS:
$data = $authAdapter->getResultRowObject();
$session->role = $data->role;
$this->_redirect('/post/retrieve');
break;
}
} else {
$form->populate($formData);
}
}
$this->view->form = $form;
}
示例12: login
/**
* This method logs in the user
* Member login
* @author Kashif Irshad
* @param string $userName
* @param string $password in md5 encryption
* @return string return 'success' for successfully login and all other messages are error message
*/
public function login($userName, $password, $remember)
{
$userTable = new Application_Model_DbTable_User();
$authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter());
$authAdapter->setTableName('users');
$authAdapter->setIdentityColumn('username');
$authAdapter->setCredentialColumn('password');
$authAdapter->setIdentity($userName);
$authAdapter->setCredential($password);
$authAdapter->setAmbiguityIdentity(true);
$auth = Zend_Auth::getInstance();
$auth->setStorage(new Zend_Auth_Storage_Session('user'));
$result = $auth->authenticate($authAdapter);
if ($result->isValid()) {
if ($remember > 0) {
$oneMinute = 60;
$oneHour = $oneMinute * 60;
$oneDay = $oneHour * 24;
$oneWeek = $oneDay * 7;
$oneMonth = $oneDay * 30;
Zend_Session::rememberMe($oneWeek);
}
return 'success';
} else {
$userRow = $userTable->fetchRow("username='{$userName}'");
if (isset($userRow)) {
return 'Invalid password';
} else {
return 'Invalid username or password';
}
}
}
示例13: getAuthAdapter
public function getAuthAdapter($values)
{
$authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table_Abstract::getDefaultAdapter(), 'Utenti', 'Username', 'Password');
$authAdapter->setIdentity($values['username']);
$authAdapter->setCredential($values['password']);
return $authAdapter;
}
示例14: 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;
}
示例15: loginAction
public function loginAction()
{
$loginForm = new Form_Auth_Login();
if ($loginForm->isValid($_POST)) {
# Better to use more secure hash method, using md5 just to explain and simplicity
$authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter(), 'users', 'username', 'password', 'MD5(?)');
# alternaitive to above
// $authAdapter->setTableName('users')
// ->setIdentityColumn('username')
// ->setCredentialColumn('password')
// ->setCredentialTreatment('MD5(?)');
// putting the form values to adapter, so in future it can be verify
$authAdapter->setIdentity($loginForm->getValue('username'));
$authAdapter->setCredential($loginForm->getValue('password'));
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate($authAdapter);
if ($result->isValid()) {
$this->_helper->FlashMessenger('Login successful');
// setting the message, so in view it can be display
$this->view->message = $this->_helper->flashMessenger->getMessages();
if ($loginForm->getValue('username') == 'admin') {
$this->_helper->FlashMessenger('Welcome Admin');
$this->view->message = $this->_helper->flashMessenger->getMessages();
$this->_redirect('user/index');
//$this->_redirect('http://google.com');
}
return;
} else {
echo "failed";
}
}
$this->view->loginForm = $loginForm;
}