コード例 #1
0
 /**
  * login from HTTP post 
  * 
  * redirects the tine main screen if authentication is successful
  * otherwise redirects back to login url 
  */
 public function loginFromPost($username, $password)
 {
     Tinebase_Core::startCoreSession();
     if (!empty($username)) {
         // try to login user
         $success = Tinebase_Controller::getInstance()->login($username, $password, Tinebase_Core::get(Tinebase_Core::REQUEST), self::REQUEST_TYPE) === TRUE;
     } else {
         $success = FALSE;
     }
     if ($success === TRUE) {
         $this->_setJsonKeyCookie();
         $ccAdapter = Tinebase_Auth_CredentialCache::getInstance()->getCacheAdapter();
         if (Tinebase_Core::isRegistered(Tinebase_Core::USERCREDENTIALCACHE)) {
             $ccAdapter->setCache(Tinebase_Core::getUserCredentialCache());
         } else {
             Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' Something went wrong with the CredentialCache / no CC registered.');
             $success = FALSE;
             $ccAdapter->resetCache();
         }
     }
     $request = new Sabre\HTTP\Request();
     $redirectUrl = str_replace('index.php', '', $request->getAbsoluteUri());
     // authentication failed
     if ($success !== TRUE) {
         $_SESSION = array();
         Tinebase_Session::destroyAndRemoveCookie();
         // redirect back to loginurl if needed
         $redirectUrl = Tinebase_Config::getInstance()->get(Tinebase_Config::REDIRECTURL, $redirectUrl);
     }
     // load the client with GET
     header('Location: ' . $redirectUrl);
 }
コード例 #2
0
 /**
  * returns protocol + hostname
  * 
  * @return string
  */
 public static function getHostname()
 {
     $hostname = self::get('HOSTNAME');
     if (!$hostname) {
         $request = new Sabre\HTTP\Request();
         $hostname = strlen($request->getUri()) > 1 ? str_replace($request->getUri(), '', $request->getAbsoluteUri()) : $request->getAbsoluteUri();
         self::set('HOSTNAME', $hostname);
     }
     return $hostname;
 }