Skip to content

Instantly share code, notes, and snippets.

@ixti
Created June 5, 2010 08:22
Show Gist options
  • Select an option

  • Save ixti/426448 to your computer and use it in GitHub Desktop.

Select an option

Save ixti/426448 to your computer and use it in GitHub Desktop.
<?php //file: application/modules/admin/controllers/IndexController.php
class Admin_IndexController extends Zend_Controller_Admin
{
public function init()
{
$request = $this->getRequest();
$auth = App_Auth_Admin::getInstance();
if (!$auth->hasIdentity() && ('login' !== $request->getActionName())) {
$this->_helper->getHelper('Redirector')
->gotoSimple('index', 'login', 'admin');
}
}
// ...
}
<?php //file: library/App/Auth.php
class App_Auth extends Zend_Auth
{
protected function __construct()
{
$this->setStorage(new Zend_Auth_Storage_Session(getclass($this)));
}
}
<?php //file: library/App/Auth/Admin.php
class App_Auth_Admin extends App_Auth
{}
<?php //file: library/App/Auth/User.php
class App_Auth_User extends App_Auth
{}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment