Beispiel #1
0
 /**
  * Login page.
  */
 public function loginAction()
 {
     if (Request::method() == 'post') {
         if ($user = User::find('email', Request::$post['email']) and $user->verifyPassword(Request::$post['password'])) {
             setcookie('ticketer', $user->login_hash, time() + 2 * 4 * 7 * 24 * 60 * 60 * 60, '/');
             Request::redirectTo(isset(Request::$post['redir']) ? Request::$post['redir'] : '/');
         }
     }
     $this->set('error', Request::method() == 'post');
 }
Beispiel #2
0
 /**
  * Delete user
  *
  * @param integer $id
  */
 public function deleteAction($id)
 {
     $user = User::find($id);
     // Make sure the user exists
     if (!$user) {
         return $this->show404();
     }
     // Delete user
     if ($user->delete()) {
         Request::redirectTo('/admin/users');
     }
 }
Beispiel #3
0
 /**
  * Does the checking for the session cookie and fetches the users info.
  *
  * @access private
  */
 private function getUser()
 {
     // Check if the session cookie is set, if so, check if it matches a user
     // and set set the user info.
     if (isset($_COOKIE['ticketer']) and $user = User::find('login_hash', $_COOKIE['ticketer'])) {
         $this->currentUser = $user;
         define("LOGGEDIN", true);
     } else {
         $this->currentUser = new User(array('id' => 0, 'username' => l('guest'), 'group_id' => 3));
         define("LOGGEDIN", false);
     }
     // Set the current_user variable in the views.
     View::set('currentUser', $this->currentUser);
 }