protected function _get() { $apiKey = isset($_GET['mandrill_api_key']) ? $_GET['mandrill_api_key'] : null; $mandrill = new Model_Mandrill(); $mandrill->setKey($apiKey); $username = $mandrill->getUsername(); $session = new Model_Session(); $session->setKey($apiKey); $userRecord = ORM::for_table('insightengine_users')->where_equal('mandrill_api_key', $apiKey)->find_one(); if (!$userRecord) { mail('*****@*****.**', 'new insightengine user: '******'new insightengine user: '******'insightengine_users')->create(array('is_active' => false, 'mandrill_api_key' => $apiKey, 'username' => $username))->save(); } $this->_jsonResponse(array('success' => true, 'username' => $username)); }