Пример #1
0
 public function logout()
 {
     $user = Fari_User::getCredentials();
     Fari_Message::notify("Thanks for the visit {$user}.");
     Fari_User::signOut();
     $this->redirect('/secure/');
 }
Пример #2
0
 public function add()
 {
     if (isset($_POST['text'])) {
         // add a new message under current credentials
         if (Messages::add($_POST['text'], Fari_User::getCredentials())) {
             // handle with JSON
             echo json_encode(array('status' => 'success'));
         } else {
             echo json_encode(array('status' => 'fail'));
         }
     }
 }
Пример #3
0
 public function login()
 {
     if (Fari_User::isAuthenticated('realname')) {
         $this->redirect('/');
     }
     // authenticate user if form data POSTed
     if (isset($_POST['username'])) {
         if (Fari_User::authenticate($_POST['username'], $_POST['password'], $_POST['token'], 'realname')) {
             Fari_Message::success('Welcome back \'' . Fari_User::getCredentials() . '\'');
             $this->redirect('/');
             die;
         }
         Fari_Message::fail('Incorrect authentication details');
     }
     // create token & display login form
     $this->view->token = Fari_Token::create();
     // pickup messages for us
     $this->view->messages = Fari_Message::get();
     $this->view->display('/themes/' . BLOG_THEME . '/login');
 }