69 lines
2.7 KiB
PHP
69 lines
2.7 KiB
PHP
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
/**
|
|
* This class provides the default template controller for rendering pages.
|
|
*
|
|
* @package lnAuth
|
|
* @category Controllers
|
|
* @author Deon George
|
|
* @copyright (c) 2014 Deon George
|
|
* @license http://dev.leenooks.net/license.html
|
|
*/
|
|
abstract class lnAuth_Controller_TemplateDefault extends lnApp_Controller_TemplateDefault {
|
|
protected $auth_required = TRUE;
|
|
|
|
protected function _auth_required() {
|
|
// If our global configurable is disabled, then continue
|
|
if (! Kohana::$config->load('config')->method_security)
|
|
return FALSE;
|
|
|
|
if (Kohana::$config->load('debug')->method_security) {
|
|
echo Debug::vars(array(
|
|
'm'=>__METHOD__,
|
|
'POST'=>$this->request->post(),
|
|
'auth_required'=>serialize($this->auth_required),
|
|
'secure_actions'=>$this->secure_actions,
|
|
'this_action'=>$this->request->action(),
|
|
'line 1 test'=>serialize(($this->auth_required !== FALSE && Auth::instance()->logged_in(NULL,get_class($this).'|'.__METHOD__) === FALSE)),
|
|
'line 2 test'=>serialize($x=is_array($this->secure_actions) && array_key_exists($this->request->action(),$this->secure_actions)),
|
|
'line 3 test'=>$x ? Auth::instance()->logged_in($this->secure_actions[$this->request->action()],get_class($this).'|'.__METHOD__) : 'NOT EVAL',
|
|
));
|
|
die();
|
|
}
|
|
|
|
return parent::_auth_required();
|
|
}
|
|
|
|
public function before() {
|
|
if ($this->auth_required) {
|
|
if (! count($this->secure_actions) OR (! isset($this->secure_actions[Request::current()->action()])))
|
|
throw HTTP_Exception::factory(403,'Class has no security defined :class, or no security configured for :method',array(':class'=>get_class($this),':method'=>Request::current()->action()));
|
|
|
|
$this->ao = Auth::instance()->get_user();
|
|
|
|
if (! is_null($this->ao) AND (is_string($this->ao)))
|
|
throw HTTP_Exception::factory(501,'Account doesnt exist :account ?',array(':account'=>(is_string($this->ao) OR is_null($this->ao)) ? $this->ao : Auth::instance()->get_user()->id));
|
|
}
|
|
|
|
return parent::before();
|
|
}
|
|
|
|
protected function setup(array $config_items=array()) {
|
|
$mo = ORM::factory('Module',array('name'=>Request::current()->controller()));
|
|
if (! $mo->loaded())
|
|
throw HTTP_Exception::factory(501,'Unknown module :module',array(':module'=>Request::current()->controller()));
|
|
|
|
if ($_POST AND isset($_POST['module_config'][$mo->id]))
|
|
Config::instance()->module_config($mo->name,$_POST['module_config'][$mo->id])->save();
|
|
|
|
if ($config_items) {
|
|
Block::factory()
|
|
->title('Update Module Configuration')
|
|
->title_icon('icon-wrench')
|
|
->type('form-horizontal')
|
|
->body(View::factory('setup/admin/module')->set('o',Company::instance()->so())->set('mid',$mo->id));
|
|
}
|
|
}
|
|
}
|
|
?>
|