/** * @see parent * * @param Bronto_Api $api * @param string $sessionId */ public function onAfterLogin($api, $sessionId) { try { $this->setToken($api->getToken())->setSessionId($sessionId)->setCreatedAt(Mage::getSingleton('core/date')->gmtDate())->save(); Mage::helper('bronto_common')->writeDebug("Initiating API for token: {$this->getToken()}"); } catch (Exception $e) { Mage::helper('bronto_common')->writeError("Failed to update API {$this->getToken()} Session: " . $e->getMessage()); } }
/** * @see parent * * @param Bronto_Api $api */ public function onBeforeLogin($api) { if ($this->hasSetSession()) { $this->unsSessionId(); Mage::helper('bronto_common')->writeDebug('Session ID expired for token: ' . $this->getToken()); $this->_setOnce = false; } else { try { parent::load($api->getToken()); if ($this->hasSessionId()) { $api->setSessionId($this->getSessionId()); Mage::helper('bronto_common')->writeDebug('Hitting API sessionId cache for token: ' . $this->getToken()); $this->_setOnce = true; } } catch (Exception $e) { // Swallow read exceptions, in case of FTP install Mage::helper('bronto_common')->writeError('Failed to read from api session table: ' . $e->getMessage()); } } }