cacert-testmgr/manager/library/plugins/plugin.forceauth.php

30 lines
1 KiB
PHP
Raw Normal View History

<?php
/**
* @author markus
* $Id: plugin.forceauth.php 40 2009-12-21 09:40:43Z markus $
*/
class ForceAuth extends Zend_Controller_Plugin_Abstract {
2015-08-09 17:12:51 +00:00
public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) {
$session = Zend_Registry::get('session');
2015-08-09 17:12:51 +00:00
if (in_array($request->getControllerName(), array('login', 'error', 'js', 'img', 'css')))
return;
2015-08-09 17:12:51 +00:00
if (!isset($session->authdata) || !isset($session->authdata['authed']) || $session->authdata['authed'] === false) {
$fc = Zend_Controller_Front::getInstance();
2015-08-09 17:12:51 +00:00
$response = $fc->getResponse();
$response->canSendHeaders(true);
2015-08-09 17:12:51 +00:00
$response->setHeader('Location', 'login', true);
$response->setHeader('Status', '301', true);
Log::Log()->debug('redirected to login');
2015-08-09 17:12:51 +00:00
$request->setModuleName('default')
->setControllerName('login')
->setActionName('index')
->setDispatched(false);
}
}
}