Exemple #1
0
 public static function instance()
 {
     if (!isset(Liauth::$_instance)) {
         // Load the configuration for this type
         $config = Kohana::config('liauth');
         if (!($type = $config->get('driver'))) {
             $type = 'Jelly';
         }
         // Set the session class name
         $class = 'Liauth_' . ucfirst($type);
         // Create a new session instance
         Liauth::$_instance = new $class($config);
     }
     return Liauth::$_instance;
 }
Exemple #2
0
 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);
     }
 }
Exemple #3
0
 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))));
 }