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


PHP Zend_Auth类代码示例

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


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

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

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

示例3: testSuccess

 public function testSuccess()
 {
     $this->adapter->setIdentity('test')->setCredential('test');
     $result = $this->auth->authenticate($this->adapter);
     $this->assertTrue($result->isValid());
     $this->assertEquals(Zend_Auth_Result::SUCCESS, $result->getCode());
     $this->assertTrue(is_object($this->adapter->getResultUserData()));
 }
开发者ID:utachkin,项目名称:Rediska,代码行数:8,代码来源:Auth.php

示例4: testFailure

 /**
  * Ensure expected behavior upon authentication failure
  *
  * @return void
  */
 public function testFailure()
 {
     $auth = new Zend_Auth(new Zend_AuthTest_Failure_Adapter(), false);
     $options = array();
     $token = $auth->authenticate($options);
     $this->assertFalse($token->isValid());
     $this->assertTrue('someIdentity' === $token->getIdentity());
     $this->assertTrue('Failure Message' === $token->getMessage());
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:14,代码来源:AuthTest.php

示例5: preDispatch

 /**
  * Check permissions before dispatch process
  *
  * @throws Zend_Auth_Adapter_Exception if answering the authentication query is impossible
  * @param Zend_Controller_Request_Abstract $request
  * @return void
  */
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $resource = $request->getControllerName();
     $action = $request->getActionName();
     if ($this->_auth->hasIdentity()) {
         $identity = $this->_auth->getStorage()->read();
         $role = $identity->role;
     } else {
         $role = $this->_defaultRole;
     }
     if ($this->_acl->has($resource) && !$this->_acl->isAllowed($role, $resource, $action)) {
         $request->setControllerName('error')->setActionName('deny');
     }
 }
开发者ID:nuxwin,项目名称:i-PMS,代码行数:21,代码来源:PermissionsCheck.php

示例6: preDispatch

 /**
  * preDispatch
  *
  * Funcion que se ejecuta antes de que lo haga el FrontController
  *
  * @param Zend_Controller_Request_Abstract $request Peticion HTTP realizada
  * @return
  * @uses Zend_Auth
  *
  */
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $controllerName = $request->getControllerName();
     // Si el usuario esta autentificado
     if ($this->_auth->hasIdentity()) {
     } else {
         // Si el Usuario no esta identificado y no se dirige a la página de Login
         if ($controllerName != 'login') {
             // Mostramos al usuario el Formulario de Login
             $request->setControllerName("login");
             $request->setActionName("index");
         }
     }
 }
开发者ID:JosefinaArayaTapia,项目名称:Capicua-Restobar,代码行数:24,代码来源:CheckAccess.php

示例7: getInstance

 /**
  * Returns an instance of Zend_Auth
  *
  * Singleton pattern implementation
  *
  * @return Zend_Auth Provides a fluent interface
  */
 public static function getInstance()
 {
     if (null === self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:14,代码来源:Auth.php

示例8: preDispatch

 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $auth = Zend_Auth::getInstance();
     $isAllowed = false;
     $controller = $request->getControllerName();
     $action = $request->getActionName();
     // Generate the resource name
     $resourceName = $controller . '/' . $action;
     // Don't block errors
     if ($resourceName == 'error/error') {
         return;
     }
     $resources = $this->acl->getResources();
     if (!in_array($resourceName, $resources)) {
         $request->setControllerName('error')->setActionName('error')->setDispatched(true);
         throw new Zend_Controller_Action_Exception('This page does not exist', 404);
         return;
     }
     // Check if user can access this resource or not
     $isAllowed = $this->acl->isAllowed(Zend_Registry::get('role'), $resourceName);
     // Forward user to access denied or login page if this is guest
     if (!$isAllowed) {
         if (!Zend_Auth::getInstance()->hasIdentity()) {
             $forwardAction = 'login';
         } else {
             $forwardAction = 'deny';
         }
         $request->setControllerName('index')->setActionName($forwardAction)->setDispatched(true);
     }
 }
开发者ID:georgepaul,项目名称:socialstrap,代码行数:30,代码来源:AccessCheck.php

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

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

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

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

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

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

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


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