/**
  * Singleton
  * @return Application_Model_AuthSessionsMapper
  */
 public static function i()
 {
     if (self::$_instance == null) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Esempio n. 2
0
 public function getCurrentUser($checkAltSession = false)
 {
     if ($this->isLoggedIn(false)) {
         return $this->_ns->username;
     } else {
         if ($checkAltSession) {
             $session = new Application_Model_AuthSession();
             if (Application_Model_AuthSessionsMapper::i()->fetchByIpUserAgent($_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT'], $session)) {
                 return $session->getUsername();
             } else {
                 throw new Exception("User not authenticated");
             }
         } else {
             throw new Exception("User not authenticated (in normal way)");
         }
     }
 }