Exemplo n.º 1
0
 /**
  * Log in as a user
  *
  *  ## OPTIONS
  * [<email>]
  * : Email address to log in as.
  *
  * [--password=<value>]
  * : Log in non-interactively with this password. Useful for automation.
  *
  * [--machine-token=<value>]
  * : Authenticate using an Auth0 token
  *
  * [--debug]
  * : dump call information when logging in.
  */
 public function login($args, $assoc_args)
 {
     // Try to login using a machine token, if provided.
     if (isset($assoc_args['machine-token']) || empty($args) && isset($_SERVER['TERMINUS_MACHINE_TOKEN'])) {
         $token = $_SERVER['TERMINUS_MACHINE_TOKEN'];
         if (isset($assoc_args['machine-token'])) {
             $token = $assoc_args['machine-token'];
         }
         $this->auth->logInViaMachineToken($token);
     } else {
         // Otherwise, do a normal email/password-based login.
         if (empty($args)) {
             if (isset($_SERVER['TERMINUS_USER'])) {
                 $email = $_SERVER['TERMINUS_USER'];
             } else {
                 $email = Terminus::prompt('Your email address?', null);
             }
         } else {
             $email = $args[0];
         }
         if (isset($assoc_args['password'])) {
             $password = $assoc_args['password'];
         } else {
             $password = Terminus::promptSecret('Your dashboard password (input will not be shown)');
         }
         $this->auth->logInViaUsernameAndPassword($email, $password);
     }
     $this->log()->debug(get_defined_vars());
     Terminus::launchSelf('art', array('fist'));
 }
Exemplo n.º 2
0
 public function testLaunchSelf()
 {
     $file_name = '/tmp/output';
     setOutputDestination($file_name);
     $return = Terminus::launchSelf("art unicorn > {$file_name}");
     $output = retrieveOutput($file_name);
     $this->assertTrue(strpos($output, "<.'_.''") !== false);
     $this->assertEquals($return, 0);
     resetOutputDestination($file_name);
 }
Exemplo n.º 3
0
 public function testLaunchSelf()
 {
     $file_name = '/tmp/output';
     //Testing the library route
     setOutputDestination($file_name);
     $return = Terminus::launchSelf("art unicorn > {$file_name}");
     $output = retrieveOutput($file_name);
     $this->assertTrue(strpos($output, "<.'_.''") !== false);
     $this->assertEquals($return, 0);
     resetOutputDestination($file_name);
     //Testing the command-line route
     setOutputDestination($file_name);
     $GLOBALS['argv'] = [__DIR__ . '/../../php/boot-fs.php'];
     $return = Terminus::launchSelf("art unicorn > {$file_name}");
     $output = retrieveOutput($file_name);
     $this->assertTrue(strpos($output, "<.'_.''") !== false);
     $this->assertEquals($return, 0);
     resetOutputDestination($file_name);
 }
Exemplo n.º 4
0
 /**
  * Create a new site
  *
  * ## OPTIONS
  *
  * [--site=<site>]
  * : Name of the site to create (machine-readable)
  *
  * [--name=<name>]
  * : (deprecated) use --site instead
  *
  * [--label=<label>]
  * : Label for the site
  *
  * [--upstream=<upstreamid>]
  * : Specify the upstream upstream to use
  *
  * [--org=<id>]
  * : UUID of organization into which to add this site
  *
  */
 public function create($args, $assoc_args)
 {
     $options = Sites_Command::getSiteCreateOptions($assoc_args);
     $upstream = Input::upstream($assoc_args, 'upstream');
     $options['upstream_id'] = $upstream->get('id');
     $this->log()->info("Creating new {upstream} installation ... ", array('upstream' => $upstream->get('longname')));
     $workflow = $this->sites->addSite($options);
     $workflow->wait();
     $this->workflowOutput($workflow);
     // Add Site to SitesCache
     $final_task = $workflow->get('final_task');
     $this->sites->addSiteToCache($final_task->site_id);
     Terminus::launchSelf('site', array('info'), array('site' => $options['name']));
     return true;
 }
Exemplo n.º 5
0
Arquivo: auth.php Projeto: andrefy/cli
 private function _checkSession()
 {
     if (!property_exists($this, "session") || !property_exists($this->session, "user_uuid")) {
         return false;
     }
     $results = $this->terminus_request("user", $this->session->user_uuid, "profile", "GET");
     if ($results['info']['http_code'] >= 400) {
         $this->failure('Your session is expired. Please reauthenticate.');
         $this->cache->remove('session');
         Terminus::launchSelf("auth", array("login"));
         $this->whoami();
         return true;
     } else {
         return $results['info']['http_code'] <= 199 || $results['info']['http_code'] >= 300 ? false : true;
     }
 }