Skip to content

Instantly share code, notes, and snippets.

@bognerf
Created June 25, 2013 12:29
Show Gist options
  • Save bognerf/5858064 to your computer and use it in GitHub Desktop.
Save bognerf/5858064 to your computer and use it in GitHub Desktop.
Front Controller plugin for Zend Framework 1 to automatically check wether user is logged in or not
<?php
class Modul_Plugin_Login extends Zend_Controller_Plugin_Abstract
{
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$credentials = FUNCION_IS_LOGGED_IN();
if (!Default_Model_Base::RZAccountIsValid($credentials->ndsaccount))
{
$request->setModuleName('ausleihe')
->setControllerName('user')
->setActionName('login-form')
->setDispatched(true);
}
}
}
<?php
class Modul_UserController extends Zend_Controller_Action
{
public function init()
{
$front = Zend_Controller_Front::getInstance();
$front->registerPlugin(new Module_Plugin_Login());
$this->view->credentials = FUNCION_IS_LOGGED_IN();
}
public function indexAction()
{
}
public function logoutAction()
{
}
public function loginAction()
{
}
public function loginFormAction()
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment