public function before() { parent::before(); $this->auth = Auth::instance(); if (is_object($this->template)) { $this->template->bind_global('auth', $this->auth); } $controller = $this->request->controller; // default role $action = $this->request->action; $role = $controller . '.' . $action; if (array_key_exists($action, $this->access)) { $role = $this->access[$action]; } else { if (isset($this->access[TRUE])) { $role = $this->access[TRUE]; } } if (empty($role)) { return; // if $role is NULL, FALSE (empty) allow for all users, even not logged } $role = strtr($role, array(':controller' => $controller, ':action' => $action)); if ($this->auth->logged_in()) { if (!$this->auth->has_role($role)) { // role required: $role $this->request->redirect($this->redirect_url); } // else: passed - allowed to action } else { // not logged in $this->session->set('referrer', Request::instance()->uri()); $this->request->redirect($this->login_url); } }
public function before() { parent::before(); if (Auth::has_access('country.read') == false) { Session::set_flash("error", "List of countries is very secret!"); Response::redirect("/") and die; } }
public function before() { parent::before(); $this->_auth = Auth::instance(); $userids = $this->_auth->get_user_id(); $this->_user_id = $userids[1]; //loads messages for event controller Lang::load("event"); }
public function before() { if (Auth::instance()->logged_in() == false) { exit; } else { $user = Auth::instance()->get_user(); $this->user_id = $user->id; } parent::before(); }
public function before() { parent::before(); $this->auth = Liauth::instance(); if (is_object($this->template)) { $this->template->bind_global('auth', $this->auth); } if (in_array($this->request->action, $this->allow)) { return; } if ($this->auth->logged_in()) { if (!$this->auth->user->active) { $this->request->redirect($this->redirect_url); } } else { // not logged in $this->session->set('referrer', Request::instance()->uri()); $this->request->redirect($this->login_url); } }