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); } }
public static function initialize(Jelly_Meta $meta) { $meta->name_key('username')->sorting(array('username' => 'ASC'))->fields(array('id' => new Field_Primary(), 'username' => new Field_String(array('unique' => TRUE, 'rules' => array('not_empty' => NULL, 'regex' => array('/^[\\pL_.-]+$/ui')))), 'password' => new Field_Password(array('hash_with' => array(Liauth::instance(), 'hash_password'), 'rules' => array('not_empty' => NULL))), 'password_confirm' => new Field_Password(array('in_db' => FALSE, 'rules' => array('not_empty' => NULL, 'matches' => array('password')))), 'active' => new Field_Boolean(array('label' => 'Aktywny', 'default' => TRUE)))); }