Example #1
0
 /**
  * Destroy user session
  */
 public function actionLogout()
 {
     try {
         // we might not be signed in actually
         $this->user = new User();
     } catch (UserNotAuthenticatedException $e) {
         $this->flashSuccess = 'You are already logged out';
     }
     // as we are logging out, leave us from all rooms
     if ($this->user != NULL) {
         $inRooms = $this->user->inRooms();
         if (!empty($inRooms)) {
             $time = mktime();
             foreach ($inRooms as $room) {
                 // message about it
                 $message = new MessageSpeak($room, $time);
                 $message->leave($room, $time, $this->user->getShortName());
             }
             // remove us from participants
             $room = new Room();
             $room->removeParticipant($this->user->getId());
         }
         $this->flashSuccess = 'You have been logged out';
         $this->user->signOut();
     }
     $this->bag->token = Fari_FormToken::create();
     $this->renderAction('login');
 }
Example #2
0
 /**
  * Destroy user session.
  */
 public function actionLogout()
 {
     try {
         $user = new AuthUser();
         $user->signOut();
         $this->flashSuccess = "You have been logged out";
     } catch (AuthUserNotAuthenticatedException $e) {
         $this->flashSuccess = 'You are already logged out';
     }
     // create token & display login form
     $this->bag->token = Fari_FormToken::create();
     $this->renderAction('login');
 }
 public function actionLogin()
 {
     // authenticate user if form data POSTed
     if ($this->request->getPost('username')) {
         $username = Fari_Decode::accents($this->request->getPost('username'));
         $password = Fari_Decode::accents($this->request->getPost('password'));
         $this->user = new Fari_AuthenticatorSimple();
         if ($this->user->authenticate($username, $password, $this->request->getPost('token'))) {
             $this->redirectTo('/');
         } else {
             $this->flashFail = 'Sorry, your username or password wasn\'t recognized';
         }
     }
     $this->flashNotify = 'Use \'admin\' for username and password.';
     // create token & display login form
     $this->bag->token = Fari_FormToken::create();
     $this->renderAction();
 }
 /**
  * Validate token data through Fari_FormToken.
  * @param mixed $token
  * @return boolean TRUE on success
  */
 public function validateToken($token)
 {
     return Fari_FormToken::isValid($token);
 }