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


PHP Zend_Auth::getIdentity方法代码示例

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


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

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

示例2: _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

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

示例4: _isAuthorized

 protected function _isAuthorized($controller, $action)
 {
     $this->_acl = Zend_Registry::get('acl');
     $user = $this->_auth->getIdentity();
     if (!$this->_acl->has($controller) || !$this->_acl->isAllowed($user, $controller, $action)) {
         return false;
     }
     return true;
 }
开发者ID:rossanorb,项目名称:zend_acl,代码行数:9,代码来源:Auth.php

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

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

示例7: getPanel

 /**
  * Gets content panel for the Debugbar
  *
  * @return string
  */
 public function getPanel()
 {
     $username = 'Not Authed';
     $role = 'Unknown Role';
     if ($this->_auth->hasIdentity()) {
         foreach ($this->_auth->getIdentity() as $property => $value) {
             $this->message->addRow(array((string) $property, (string) $value));
         }
     } else {
         //			$this->message->setMessage('Not authorized');
     }
     return '';
 }
开发者ID:vahid-sohrabloo,项目名称:ZFirebug,代码行数:18,代码来源:Auth.php

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

示例9: preDispatch

 /**
  * Called before an action is dispatched by Zend_Controller_Dispatcher.
  *
  * This callback allows for proxy or filter behavior.  By altering the
  * request and resetting its dispatched flag (via
  * {@link Zend_Controller_Request_Abstract::setDispatched() setDispatched(false)}),
  * the current action may be skipped.
  *
  * @param  Zend_Controller_Request_Abstract $request
  * @return void
  */
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     // reset role & resource
     Zend_Registry::set('Role', 'guest');
     Zend_Registry::set('Resource', '');
     // check if ErrorHandler wasn't fired
     if ($request->getParam('error_handler')) {
         return;
     }
     $module = $request->getModuleName();
     $controller = $request->getControllerName();
     $action = $request->getActionName();
     $pathInfo = $request->getPathInfo();
     $allow = false;
     if ($this->_auth->hasIdentity()) {
         $userId = $this->_auth->getIdentity();
         $roleId = $this->_auth->getRoleId();
         $rolesList = $this->_em->find('Roles', $roleId);
         $roleName = $rolesList->getRoleName();
         $role = new Zend_Acl_Role($roleName);
     } else {
         $roleName = 'guest';
         $role = new Zend_Acl_Role($roleName);
     }
     $resource = $action == '' ? trim($controller) . '/index' : trim($controller) . '/' . trim($action);
     $resource = $module == 'default' ? $resource : $module . "/" . $resource;
     // on main page resource might be empty
     if ($resource == '') {
         $resource = 'index/index';
     }
     // if resource not exist in db then check permission for controller
     if (!$this->_acl->has($resource) && $action != '') {
         $resource = trim($controller);
     }
     // check if user is allowed to see the page
     $allow = $this->_acl->isAllowed($role, $resource);
     if ($allow == false && $this->_auth->hasIdentity()) {
         // user logged in but denied permission
         $request->setModuleName('default');
         $request->setControllerName('error');
         $request->setActionName('forbidden');
         /* $this->_response->setHeader('Content-type', 'text/html');
                       $this->_response->setHttpResponseCode(403);
                       $this->_response->setBody('<h1>403 - Forbidden</h1>');
         
                       $this->_response->sendResponse(); */
     }
     Zend_Registry::set('Role', $role);
     Zend_Registry::set('Resource', $resource);
 }
开发者ID:uppaljs,项目名称:pakistan-vlmis-v2,代码行数:61,代码来源:Acl.php

示例10: authInfo

 /**
  * Get authenticated users info
  *
  * @param  object $inf (optional)
  * @return logged users info
  */
 public function authInfo($info = null)
 {
     if ($this->_zendAuth === null) {
         $this->_zendAuth = Zend_Auth::getInstance();
     }
     if ($info === null) {
         return $this;
     }
     if (false === $this->isLoggedIn()) {
         return null;
     }
     $arrayObj = new ArrayObject($this->_zendAuth->getIdentity());
     $iterator = $arrayObj->getIterator();
     return $iterator[$info];
 }
开发者ID:Ewaldaz,项目名称:Be-your-light,代码行数:21,代码来源:Authentication.php

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

示例12: preDispatch

 /**
  * Hook into action controller preDispatch() workflow
  *
  * @return void
  */
 public function preDispatch()
 {
     $role = 'guest';
     //        die($role);
     if ($this->_auth->hasIdentity()) {
         $user = $this->_auth->getIdentity();
         if (is_object($user)) {
             $role = $this->_auth->getIdentity()->role;
         }
     }
     $request = $this->_action->getRequest();
     $controller = $request->getControllerName();
     $action = $request->getActionName();
     $module = $request->getModuleName();
     //        $this->view->getLayout()->setLayout($module);
     $this->_controllerName = $controller;
     $resource = $controller;
     $privilege = $action;
     if (!$this->_acl->has($resource)) {
         $resource = null;
     }
     if (!$this->_acl->isAllowed($role, $resource, $privilege)) {
         if (!$this->_auth->hasIdentity()) {
             $noPermsAction = $this->_acl->getNoAuthAction();
         } else {
             $noPermsAction = $this->_acl->getNoAclAction();
         }
         $request->setModuleName($noPermsAction['module']);
         $request->setControllerName($noPermsAction['controller']);
         $request->setActionName($noPermsAction['action']);
         $request->setDispatched(false);
     }
 }
开发者ID:harleyflh75,项目名称:testing,代码行数:38,代码来源:Acl.php

示例13: preDispatch

 /**
  * Hook into action controller preDispatch() workflow
  *
  * @return void
  */
 public function preDispatch()
 {
     $role = 'public';
     if ($this->_auth->hasIdentity()) {
         $user = $this->_auth->getIdentity();
         if (is_object($user)) {
             $role = $this->_auth->getIdentity()->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 (!$this->_acl->isAllowed($role, $resource, $privilege)) {
         $request->setModuleName('default');
         $request->setControllerName('error');
         $request->setActionName('error');
         $request->setDispatched(false);
     }
     /**	
     		 if (!$this->_acl->isAllowed($role, $resource, $privilege)){
     		throw new Pas_Exception_NotAuthorised('Not authorised');
     		
     		}
     
     		***/
 }
开发者ID:rwebley,项目名称:Beowulf---PAS,代码行数:38,代码来源:Acl.php

示例14: delete

 /**
  * Delete user
  *
  * @param Newscoop\Entity\User $user
  *
  * @return void
  */
 public function delete(User $user)
 {
     if ($this->auth->getIdentity() == $user->getId()) {
         throw new \InvalidArgumentException("You can't delete yourself");
     }
     $this->getRepository()->delete($user);
 }
开发者ID:sourcefabric,项目名称:newscoop,代码行数:14,代码来源:UserService.php

示例15: getIdentity

 /**
  * Allows the ACL tighter integration with the identity
  *
  * @return string
  */
 public function getIdentity()
 {
     if (null == $this->_identity && $this->_auth->hasIdentity()) {
         $this->_identity = $this->_auth->getIdentity();
     }
     return $this->_identity;
 }
开发者ID:BGCX262,项目名称:zym-svn-to-git,代码行数:12,代码来源:Acl.php


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