Beispiel #1
0
 public function action_login()
 {
     $this->template->set_global('database', FALSE);
     $this->template->set_global('table', FALSE);
     $this->template->set_global('databases', array());
     $this->template->set_global('tables', array());
     $this->view->return_to = Arr::get($_REQUEST, 'return_to', '');
     if (Arr::get($_POST, 'login', FALSE)) {
         $username = trim(Arr::get($_POST, 'username', ''));
         $password = trim(Arr::get($_POST, 'password', ''));
         try {
             $this->dbms->username($username);
             $this->dbms->password(empty($password) ? NULL : $password);
             if ($this->dbms->connect()) {
                 $this->add_flash_message('You are now logged in.', 'info');
                 $this->request->redirect($this->view->return_to);
             } else {
                 $this->add_template_message('Login failed.  Please try again.');
             }
         } catch (Exception $e) {
             $this->add_template_message($e->getMessage());
         }
     }
 }