当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Auth::clearIdentity方法代码示例

本文整理汇总了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());
     }
 }
开发者ID:roquebrasilia,项目名称:sgdoc-codigo,代码行数:37,代码来源:Authentication.php

示例2: logoutAction

 public function logoutAction()
 {
     $this->getHelper('contextSwitch')->addActionContext('logout', 'json')->initContext();
     if ($this->auth->hasIdentity()) {
         $this->auth->clearIdentity();
     }
     $this->view->response = 'OK';
 }
开发者ID:nidzix,项目名称:Newscoop,代码行数:8,代码来源:OmniboxController.php

示例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());
 }
开发者ID:nidzix,项目名称:Newscoop,代码行数:11,代码来源:AuthController.php

示例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());
 }
开发者ID:sourcefabric,项目名称:newscoop,代码行数:12,代码来源:AuthController.php

示例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;
         }
     }
 }
开发者ID:vilmarsitio,项目名称:registrodeprecos,代码行数:56,代码来源:Autenticacao.php

示例6: clearIdentity

 public function clearIdentity()
 {
     $ret = parent::clearIdentity();
     $userModel = Kwf_Registry::get('userModel');
     if ($userModel) {
         $userModel->clearAuthedUser();
     }
     return $ret;
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:9,代码来源:Auth.php

示例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');
         }
     }
 }
开发者ID:starflash,项目名称:ZtChart-ZF1-Example,代码行数:24,代码来源:Auth.php

示例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);
     }
 }
开发者ID:lesleyauk,项目名称:findsorguk,代码行数:24,代码来源:IndexController.php

示例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);
 }
开发者ID:fredcido,项目名称:simuweb,代码行数:16,代码来源:Auth.php

示例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']);
 }
开发者ID:romikring,项目名称:rcalex,代码行数:16,代码来源:Auth.php

示例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/');
     }
 }
开发者ID:lesleyauk,项目名称:findsorguk,代码行数:28,代码来源:AccountController.php

示例12: clearIdentity

 /**
  * ログアウト
  *
  * @return void
  */
 public function clearIdentity()
 {
     return parent::clearIdentity();
 }
开发者ID:noriotakei,项目名称:suraimu,代码行数:9,代码来源:ComAuth.php

示例13: clearIdentity

 /**
  * @see Zend_Auth::clearIdentity()
  */
 public function clearIdentity()
 {
     parent::clearIdentity();
     $this->_user = null;
 }
开发者ID:eugenzor,项目名称:zfhrtool,代码行数:8,代码来源:Auth.php

示例14: logout

 /**
  * Logout current user
  *
  * @return void
  */
 public function logout()
 {
     $this->_auth->clearIdentity();
     Zend_Session::forgetMe();
 }
开发者ID:JellyBellyDev,项目名称:zle,代码行数:10,代码来源:UserAbstract.php

示例15: clearIdentity

 public function clearIdentity()
 {
     $this->_identity = null;
     parent::clearIdentity();
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:5,代码来源:Auth.php


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