本文整理汇总了PHP中Zend_Auth::clearIdentity方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Auth::clearIdentity方法的具体用法?PHP Zend_Auth::clearIdentity怎么用?PHP Zend_Auth::clearIdentity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Auth
的用法示例。
在下文中一共展示了Zend_Auth::clearIdentity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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());
}
}
示例2: logoutAction
public function logoutAction()
{
$this->getHelper('contextSwitch')->addActionContext('logout', 'json')->initContext();
if ($this->auth->hasIdentity()) {
$this->auth->clearIdentity();
}
$this->view->response = 'OK';
}
示例3: logoutAction
public function logoutAction()
{
if ($this->auth->hasIdentity()) {
$this->auth->clearIdentity();
}
$url = $this->_request->getParam('url');
if (!is_null($url)) {
$this->_redirect($url);
}
$this->_helper->redirector->gotoUrl('?t=' . time());
}
示例4: logoutAction
public function logoutAction()
{
if ($this->auth->hasIdentity()) {
$this->auth->clearIdentity();
}
setcookie('NO_CACHE', 'NO', time() - 3600, '/', '.' . $this->extractDomain($_SERVER['HTTP_HOST']));
$url = $this->_getParam('url');
if (!is_null($url)) {
$this->_redirect($url);
}
$this->_helper->redirector->gotoUrl('?t=' . time());
}
示例5: preDispatch
/**
*(non-PHPdoc)
*
* @see Zend_Controller_Plugin_Abstract::preDispatch()
*/
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
/**
* Recupera a identidade do usuario logado
*
* @var Array
*/
$role = $this->auth->getIdentity();
/**
* Recursos que se deseja acesso
*
* @var String
*/
$resource = $this->getRequest()->getModuleName();
/**
* Ação permitida dentro de um resource
*
* @var String
*/
$action = $this->getRequest()->getModuleName() != 'admin' && $this->getRequest()->getModuleName() != 'sac' ? null : $this->getRequest()->getControllerName();
// Verificação condicional para os controllers e actions de upload
if (!($request->getActionName() == 'upload' || $request->getControllerName() == 'upload')) {
// Verifica se ha lixo na autenticacao
if (!is_array($role)) {
// Parametros
$params = array();
// Destroi qualquer instancia de autenticacao
$this->auth->clearIdentity();
// Altera a rota de destino
$request->setModuleName('admin')->setControllerName('login')->setActionName('index');
return;
}
// Verifica se o recurso existe e se o usuario logado tem acesso
if (!$this->acl->has($resource) || !$this->acl->isAllowed($role['usuario'], $resource, $action)) {
// Parametros
$params = array();
// Redireciona para o controller de login
if ($role['usuario'] != 'visitante') {
$params['erro'] = 'Você não possui permissão de acesso a este recurso.';
$request->setModuleName('admin')->setControllerName('index')->setActionName('index')->setParams($params);
} else {
if ($this->getRequest()->getModuleName() == "sac") {
$request->setModuleName('sac')->setControllerName('login')->setActionName('index')->setParams($params);
} else {
$request->setModuleName('admin')->setControllerName('login')->setActionName('index')->setParams($params);
}
}
return;
}
}
}
示例6: clearIdentity
public function clearIdentity()
{
$ret = parent::clearIdentity();
$userModel = Kwf_Registry::get('userModel');
if ($userModel) {
$userModel->clearAuthedUser();
}
return $ret;
}
示例7: routeShutdown
/**
* 判断是否登陆
*
* @param Zend_Controller_Request_Abstract $request
* @return void
*/
public function routeShutdown(Zend_Controller_Request_Abstract $request)
{
if ($this->_auth->hasIdentity()) {
if (false !== ($user = $this->_checkIdentity($this->_auth->getIdentity()->user_name))) {
Zend_Registry::set('user', $user);
} else {
if (!$this->_isAllowedAnonymous($request)) {
$request->setModuleName('default')->setControllerName('index')->setActionName('forbidden');
}
$this->_auth->clearIdentity();
}
} else {
if (!$this->_isAllowedAnonymous($request)) {
// 如果当前请求的Url地址不允许匿名访问,则跳转到登陆页面。
$request->setModuleName('default')->setControllerName('login')->setActionName('index');
}
}
}
示例8: indexAction
/** Creation of the login page
* @access public
* @return void
*/
public function indexAction()
{
if (null === $this->_auth->getIdentity()) {
$form = new LoginForm();
$this->view->form = $form;
if ($this->_request->isPost() && $form->isValid($this->_request->getPost())) {
$authAdapter = $form->username->getValidator('Authorise')->getAuthAdapter();
$data = $authAdapter->getResultRowObject(NULL, 'password');
$this->_auth->getStorage()->write($data);
$this->redirect($this->_helper->loginRedirect());
} else {
$this->_auth->clearIdentity();
// $this->getFlash()->addMessage('Sorry, there was a
// problem with your submission. Please check and try again');
$form->populate($this->_request->getPost());
}
} else {
$this->redirect(self::REDIRECT);
}
}
示例9: _routeNoAuth
/**
* @access protected
* @return void
*/
protected function _routeNoAuth()
{
$this->_auth->clearIdentity();
$baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl();
if (!$this->_request->isXMLHttpRequest()) {
$this->_session->triedroute = str_replace($baseUrl, '', $this->_request->getRequestUri());
} else {
$helperBroker = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
$helperBroker->direct(array('error' => true, 'status' => false, 'logout' => true));
}
$this->_setRouter($this->_noAuth);
}
示例10: clearIdentity
public function clearIdentity()
{
$config = new Zend_Config_Ini(APPLICATION_PATH . DIRECTORY_SEPARATOR . 'configs' . DIRECTORY_SEPARATOR . 'application.ini', APPLICATION_ENV);
if ($this->hasIdentity()) {
$usersTable = new Rabotal_Model_Users();
$user = $usersTable->find($this->getIdentity()->id)->current();
if ($user) {
$user->auto_signin_key = '';
$user->save();
}
parent::clearIdentity();
}
setcookie('uid', -1, time() - self::DAYS_15, '/', $config->site->default->domain);
setcookie('ask', -1, time() - self::DAYS_15, '/', $config->site->default->domain);
unset($_COOKIE['uid'], $_COOKIE['ask']);
}
示例11: successAction
/** On success action
* @access public
* @return void
*/
public function successAction()
{
if (null === $this->_auth->getIdentity()) {
$this->view->headTitle('Login to the system');
$form = new LoginForm();
$this->view->form = $form;
if ($this->_request->isPost()) {
$formData = $this->_request->getPost();
if ($form->isValid($formData)) {
$authAdapter = $form->username->getValidator('Authorise')->getAuthAdapter();
$data = $authAdapter->getResultRowObject(null, 'password');
$this->_auth->getStorage()->write($data);
$this->redirect($this->_helper->loginRedirect());
} else {
$this->_auth->clearIdentity();
$this->getFlash()->addMessage('Sorry, there was a problem with your submission.
Please check and try again');
$form->populate($formData);
}
}
} else {
$this->redirect('/users/');
}
}
示例12: clearIdentity
/**
* ログアウト
*
* @return void
*/
public function clearIdentity()
{
return parent::clearIdentity();
}
示例13: clearIdentity
/**
* @see Zend_Auth::clearIdentity()
*/
public function clearIdentity()
{
parent::clearIdentity();
$this->_user = null;
}
示例14: logout
/**
* Logout current user
*
* @return void
*/
public function logout()
{
$this->_auth->clearIdentity();
Zend_Session::forgetMe();
}
示例15: clearIdentity
public function clearIdentity()
{
$this->_identity = null;
parent::clearIdentity();
}