/** * Destroy the SQLite database. */ public static function destroy() { $location = Sqlite::getLocation(); drush_log(dt('Destroying SQLite database at @location', array('@location' => $location))); if (file_exists($location)) { unlink($location); drush_cache_clear_all('brain_path', 'switchboard', TRUE); drush_log(dt('SQLite database removed.')); } else { drush_log(dt('SQLite database does not exist, nothing to remove.')); } }
/** * Log in to target Provider. * * @param string $email * The email address of the user. * @param string $password * The password of the user. * * @return bool * Indicates success. */ public function authLogin($email, $password) { $url = $this->endpoint . '/login'; // Get the form build ID. try { $response = \Requests::post($url); } catch (\Requests_Exception $e) { return drush_set_error('SWITCHBOARD_AUTH_LOGIN_PANTHEON_ENDPOINT_UNAVAILABLE', dt('Pantheon endpoint unavailable: @error', array('@error' => $e->getMessage()))); } $form_build_id = $this->authLoginGetFormBuildId($response->body); if (!$form_build_id) { return drush_set_error('SWITCHBOARD_AUTH_LOGIN_PANTHEON_LOGIN_UNAVAILABLE', dt('Pantheon login unavailable.')); } // Attempt to log in. try { $response = \Requests::post($url, array(), array('email' => $email, 'password' => $password, 'form_build_id' => $form_build_id, 'form_id' => 'atlas_login_form', 'op' => 'Login'), $this->requestsOptions(array('follow_redirects' => FALSE))); } catch (\Requests_Exception $e) { return drush_set_error('SWITCHBOARD_AUTH_LOGIN_PANTHEON_LOGIN_FAILURE', dt('Pantheon login failure: @error', array('@error' => $e->getMessage()))); } $session = $this->authLoginGetSessionFromHeaders($response->headers->getValues('set-cookie')); if (!$session) { return drush_set_error('SWITCHBOARD_AUTH_LOGIN_PANTHEON_NO_SESSION', dt('Pantheon Session not found; please check your credentials and try again.')); } // Get the UUID. $user_uuid = array_pop(explode('/', $response->headers->offsetGet('Location'))); if (!switchboard_validate_uuid($user_uuid)) { return drush_set_error('SWITCHBOARD_AUTH_LOGIN_PANTHEON_NO_UUID', dt('Pantheon User UUID not found; please check your credentials and try again.')); } drush_cache_clear_all('*', $this->drushCacheBinAuthName(), TRUE); drush_cache_set('user_uuid', $user_uuid, $this->drushCacheBinAuthName()); drush_cache_set('session', $session, $this->drushCacheBinAuthName()); drush_cache_set('email', $email, $this->drushCacheBinAuthName()); return TRUE; }
/** * Log out of target provider. */ public function authLogout() { drush_cache_clear_all('*', $this->drushCacheBinAuthName(), TRUE); }
/** * Log in to target Provider. * * @param string $email * The email address of the user. * @param string $password * The password of the user. * * @return bool * Indicates success. */ public function authLogin($email, $password) { drush_cache_clear_all('*', $this->drushCacheBinAuthName(), TRUE); drush_cache_set('email', $email, $this->drushCacheBinAuthName()); drush_cache_set('password', $password, $this->drushCacheBinAuthName()); return TRUE; }