Esempio n. 1
0
 public static function setupApplication()
 {
     // Set the default values
     $application = Stuffpress_Application::getInstance();
     $application->user = null;
     $application->role = 'guest';
     // Try to authenticate based on cookies
     try {
         $cookie = new Stuffpress_Cookie();
         $user_id = $cookie->validate();
     } catch (Exception $e) {
         $user_id = 0;
     }
     if ($user_id) {
         $users = new Users();
         $user = $users->getUser($user_id);
         if ($user) {
             $application->user = $user;
             $application->role = 'member';
         }
     }
 }
Esempio n. 2
0
 public function logoutAction()
 {
     // We clear the identity immediately
     $this->_application->user = false;
     $this->_application->role = 'guest';
     // Clear the cookie
     $cookie = new Stuffpress_Cookie();
     $cookie->logout();
     // Get the request parameters
     $target = $this->_getParam("target");
     // If we have a target, we go there
     if ($target) {
         return $this->_redirect($target);
     }
     // Otherwise we go back to the home page
     return $this->_redirect('/');
 }