Skip to content

Instantly share code, notes, and snippets.

@sebastianhoitz
Created November 28, 2011 17:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebastianhoitz/1401279 to your computer and use it in GitHub Desktop.
Save sebastianhoitz/1401279 to your computer and use it in GitHub Desktop.
Zend Framework Auth plugin
<?php
class App_Controller_Plugin_Auth extends Zend_Controller_Plugin_Abstract
{
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$auth = Zend_Auth::getInstance();
if (!$auth->hasIdentity()
&& !($request->getControllerName() == "session"
&& $request->getActionName() == "login"))
{
$request->setControllerName("session")
->setActionName("login")
->setModuleName("")
->setDispatched(false);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment