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


PHP Zend_Auth::hasIdentity方法代码示例

本文整理汇总了PHP中Zend_Auth::hasIdentity方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Auth::hasIdentity方法的具体用法?PHP Zend_Auth::hasIdentity怎么用?PHP Zend_Auth::hasIdentity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Auth的用法示例。


在下文中一共展示了Zend_Auth::hasIdentity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: preDispatch

 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     if ($request->getParam('sid') !== null && $request->getParam('PHPSESSID') === null) {
         $request->setParam('PHPSESSID', $request->getParam('sid'));
     }
     if ($request->getParam('PHPSESSID') === null) {
         $module = strtolower($request->getModuleName());
         $controller = strtolower($request->getControllerName());
         $action = strtolower($request->getActionName());
         $route = $module . '/' . $controller . '/' . $action;
         if (!in_array($route, $this->_whitelist)) {
             if (is_null($this->_auth)) {
                 $auth = Zend_Auth::getInstance();
                 $auth->setStorage(new Zend_Auth_Storage_Session($this->getStorage()));
                 $this->_auth = $auth;
             }
             if (!$this->_auth->hasIdentity()) {
                 $errorHandler = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
                 $errorHandler->type = 'EXCEPTION_NOT_ALLOWED';
                 $errorHandler->exception = new Zend_Controller_Action_Exception('No credentials available');
                 $errorHandler->request = clone $request;
                 $request->setParam('error_handler', $errorHandler)->setModuleName($this->getErrorHandlerModule())->setControllerName($this->getErrorHandlerController())->setActionName($this->getErrorHandlerAction());
             } else {
                 $this->_auth->getIdentity()->connect();
                 $this->_auth->getIdentity()->refresh();
             }
         }
     }
 }
开发者ID:hausdesign,项目名称:zf-library,代码行数:29,代码来源:Auth.php

示例2: isLoggedIn

 /**
  * Check, if user is logged in
  *
  * @param  no parameters
  * @return bool logged in status
  */
 public function isLoggedIn()
 {
     if ($this->_zendAuth === null) {
         $this->_zendAuth = Zend_Auth::getInstance();
     }
     return $this->_zendAuth->hasIdentity();
 }
开发者ID:Ewaldaz,项目名称:Be-your-light,代码行数:13,代码来源:Authentication.php

示例3: preDispatch

 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $controller = "";
     $action = "";
     $module = "";
     /*	if($request->getControllerName() == "index" ){
     			$controller = $request->getControllerName();
     			$action     = $request->getActionName();
     			$module     = $request->getModuleName();
     		}
     		else if ( !$this->_auth->hasIdentity() ) {
     			
     		}*/
     if (!$this->_isAuthorized($request->getControllerName(), $request->getActionName())) {
         if (!$this->_auth->hasIdentity()) {
             if (!in_array($request->getControllerName(), $this->_moRedirect) && !Application_Model_Redirect::hasRequestUri()) {
                 Application_Model_Redirect::saveRequestUri("/" . $request->getControllerName() . "/" . $request->getActionName());
             }
             $controller = $this->_notLoggedRoute['controller'];
             $action = $this->_notLoggedRoute['action'];
             $module = $this->_notLoggedRoute['module'];
         } else {
             $controller = $this->_forbiddenRoute['controller'];
             $action = $this->_forbiddenRoute['action'];
             $module = $this->_forbiddenRoute['module'];
         }
     } else {
         $controller = $request->getControllerName();
         $action = $request->getActionName();
         $module = $request->getModuleName();
     }
     $request->setControllerName($controller);
     $request->setActionName($action);
     $request->setModuleName($module);
 }
开发者ID:erickosma,项目名称:e-ong,代码行数:35,代码来源:Auth.php

示例4: indexAction

 public function indexAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $this->_redirect($this->_returnLogin);
     }
     $formLogin = new Backend_Form_Login();
     $formLogin->setAction($this->view->baseUrl() . $this->_returnLogin);
     if ($this->getRequest()->isPost()) {
         if (!$formLogin->isValid($this->_request->getPost())) {
             $formLogin->populate($this->_request->getPost());
             $this->view->formLogin = $formLogin;
         } else {
             $username = $this->getRequest()->getParam('username', '');
             $password = $this->getRequest()->getParam('password', '');
             $this->authenticate($username, $password);
             if ($this->_auth->hasIdentity()) {
                 $this->_redirect("/{$this->_module}");
             } else {
                 $this->_redirect($this->_returnLogin);
             }
         }
     }
     $this->view->formLogin = $formLogin;
 }
开发者ID:Neozeratul,项目名称:Intermodels,代码行数:25,代码来源:Login.php

示例5: preDispatch

 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $controller = "";
     $action = "";
     $module = "";
     if ($this->_isProtectedResource($request)) {
         if (!$this->_auth->hasIdentity()) {
             $controller = $this->_notLoggedRoute['controller'];
             $action = $this->_notLoggedRoute['action'];
             $module = $this->_notLoggedRoute['module'];
         } else {
             if (!$this->_isAuthorized($request->getControllerName(), $request->getActionName())) {
                 $controller = $this->_forbiddenRoute['controller'];
                 $action = $this->_forbiddenRoute['action'];
                 $module = $this->_forbiddenRoute['module'];
             } else {
                 $controller = $request->getControllerName();
                 $action = $request->getActionName();
                 $module = $request->getModuleName();
             }
         }
         $request->setControllerName($controller);
         $request->setActionName($action);
         $request->setModuleName($module);
     }
 }
开发者ID:rossanorb,项目名称:zend_acl,代码行数:26,代码来源:Auth.php

示例6: preDispatch

 /**
  * Hook into action controller preDispatch() workflow
  *
  * @return void
  */
 public function preDispatch()
 {
     $role = Zend_Registry::get('config')->acl->defaultRole;
     if ($this->_auth->hasIdentity()) {
         $user = $this->_auth->getIdentity();
         if (is_object($user) && !empty($user->role)) {
             $role = $user->role;
         }
     }
     $request = $this->_action->getRequest();
     $controller = $request->getControllerName();
     $action = $request->getActionName();
     $module = $request->getModuleName();
     $this->_controllerName = $controller;
     $resource = $controller;
     $privilege = $action;
     if (!$this->_acl->has($resource)) {
         $resource = null;
     }
     if ($resource == 'error' && $privilege == 'error') {
         return;
     }
     if (!$this->_acl->isAllowed($role, $resource, $privilege)) {
         $request->setModuleName('default')->setControllerName('auth')->setActionName('noaccess');
         $request->setDispatched(false);
         return;
     }
 }
开发者ID:crlang44,项目名称:frapi,代码行数:33,代码来源:Acl.php

示例7: getPerson

 /** Get the person's identity
  * @access public
  * @return boolean
  */
 public function getPerson()
 {
     if ($this->_auth->hasIdentity()) {
         return $this->_auth->getIdentity();
     } else {
         return false;
     }
 }
开发者ID:lesleyauk,项目名称:findsorguk,代码行数:12,代码来源:Identity.php

示例8: _isAuthorized

 protected function _isAuthorized($resource, $action)
 {
     $user = $this->_auth->hasIdentity() ? $this->_auth->getIdentity() : 'guest';
     if (!$this->_acl->has($resource) || !$this->_acl->isAllowed($user, $resource, $action)) {
         return false;
     }
     return true;
 }
开发者ID:ezequielsp,项目名称:zf1,代码行数:8,代码来源:Auth.php

示例9: 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

示例10: getCurrentUser

 /**
  * Get current user
  *
  * @return Newscoop\Entity\User
  */
 public function getCurrentUser()
 {
     if ($this->currentUser === NULL) {
         if ($this->auth->hasIdentity()) {
             $this->currentUser = $this->getRepository()->find($this->auth->getIdentity());
         }
     }
     return $this->currentUser;
 }
开发者ID:nidzix,项目名称:Newscoop,代码行数:14,代码来源:UserService.php

示例11: _checkAuth

 /**
  *
  * @return boolean 
  */
 protected function _checkAuth()
 {
     if (!$this->_auth->hasIdentity() && 'auth' !== $this->_request->getControllerName() && 'cron' !== $this->_request->getModuleName()) {
         return false;
     }
     if (!empty($this->_session->client) && 'external' !== $this->_request->getModuleName()) {
         return false;
     }
     return true;
 }
开发者ID:fredcido,项目名称:simuweb,代码行数:14,代码来源:Auth.php

示例12: getRole

 /** Get the user's role
  * @access public
  * @return string
  */
 public function getRole()
 {
     if ($this->_auth->hasIdentity()) {
         $user = $this->_auth->getIdentity();
         $role = $user->role;
     } else {
         $role = 'public';
     }
     return $role;
 }
开发者ID:lesleyauk,项目名称:findsorguk,代码行数:14,代码来源:Details.php

示例13: getPanel

    /**
     * Gets content panel for the Debugbar
     *
     * @return string
     */
    public function getPanel()
    {
        if ($this->_auth->hasIdentity()) {
            $html  = '<h4>Current Identity</h4>';
            $html .= $this->_cleanData($this->_auth->getIdentity());
            return $html;
        }

        return '';
    }
开发者ID:rchouinard,项目名称:zf-skeleton,代码行数:15,代码来源:Auth.php

示例14: __construct

 /**
  * Construtor do Plugin
  *
  * @param $acl Zend_Acl        	
  * @param $auth Zend_Auth        	
  */
 public function __construct($dbAdapter)
 {
     // Carrega todas as ACl's
     $this->acl = new Acl_Global($dbAdapter);
     // Recupera a informacao de autenticacao
     $this->auth = Zend_Auth::getInstance();
     // Adiciona o role padrao de visitante
     if (!$this->auth->hasIdentity()) {
         $authStorage = $this->auth->getStorage();
         $authStorage->write(array('usuario' => 'visitante', 'role' => 'visitante'));
     }
 }
开发者ID:vilmarsitio,项目名称:registrodeprecos,代码行数:18,代码来源:Autenticacao.php

示例15: init

 /**
  * Initialize the controller
  * sets basic info such as baseUrl
  * 
  * @return void
  */
 public function init()
 {
     parent::init();
     $this->view->baseUrl = $this->_request->getBaseUrl();
     if ($this->_authCheckRequired == true) {
         $this->_generateAuthAdapter();
         if (!$this->_auth->hasIdentity()) {
             $this->_helper->redirector->gotoRoute(array('controller' => 'login', 'action' => 'index'));
         }
     }
     $this->view->styles = array('reset.css', 'main.css', 'jquery-ui.css');
     $this->view->scripts = array('jquery.js', 'jquery-ui.js');
 }
开发者ID:rafaelcastelani,项目名称:Newsletter,代码行数:19,代码来源:BaseController.php


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