Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.43 KB | None | 0 0
  1. <?php
  2. class Admin_AuthController
  3.     extends Zend_Controller_Action
  4. {
  5.             // isPublicAction {{{
  6.         protected function isPublicAction()
  7.         {
  8.             return in_array($this->getRequest()->getActionName(), $this->_public_actions);
  9.            
  10.         }
  11.         // }}}
  12.         // isLoggedIn {{{
  13.         protected function isLoggedIn()
  14.         {
  15.             // Authenticate the user
  16.             return Zend_Auth::getInstance()->hasIdentity();
  17.         }
  18.         // }}}
  19.         // init {{{
  20.         public function init()
  21.         {
  22.            
  23.             // If not logging in or out and not authenticated
  24.             if (!($this->isPublicAction() || $this->isLoggedIn()))
  25.             {
  26.                 // Force login
  27.                 return $this->_helper->redirector->gotoUrl('/admin/index/login/');
  28.                
  29.             }
  30.  
  31.             parent::init();
  32.             $this->layout_view->nav_template = 'member';
  33.  
  34.             // paranoia check before retrieving member information
  35.             if (!$this->isPublicAction())
  36.             {
  37.                 $member_session = new Zend_Session_Namespace('member_acct_information');
  38.                 $this->view->profile = $member_session->profile;
  39.             }
  40.         }
  41.  
  42.          protected $_public_actions = array(
  43.             'view',
  44.             'forgotpassword',
  45.             'resetpassword',
  46.             'login',
  47.             'logout'
  48.         );
  49. }
  50. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement