Esempio 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.
  * [--debug]
  * : dump call information when logging in.
  */
 public function login($args, $assoc_args)
 {
     if (empty($args)) {
         $email = Terminus::prompt("Your email address?", NULL);
     } else {
         $email = $args[0];
     }
     if (\Terminus\Utils\is_valid_email($email)) {
         if (!isset($assoc_args['password'])) {
             exec("stty -echo");
             $password = Terminus::prompt("Your dashboard password (input will not be shown)");
             exec("stty echo");
             Terminus::line();
         } else {
             $password = $assoc_args['password'];
         }
         Terminus::line("Logging in as {$email}");
         $data = $this->doLogin($email, $password);
         if ($data != FALSE) {
             if (array_key_exists("debug", $assoc_args)) {
                 $this->_debug(get_defined_vars());
             }
             Terminus::launch_self("art", array("fist"));
         } else {
             Terminus::error("Login Failed!");
         }
     } else {
         Terminus::error("Error: invalid email address");
     }
 }
Esempio n. 2
0
File: auth.php Progetto: newtoid/cli
 /**
  * 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.
  * [--session=<value>]
  * : Authenticate using an existing session token
  * [--debug]
  * : dump call information when logging in.
  */
 public function login($args, $assoc_args)
 {
     # First try to login using a session token if provided
     if (isset($assoc_args['session'])) {
         Terminus::line("Validating session token");
         $data = $this->doLoginFromSessionToken($assoc_args['session']);
         if ($data != FALSE) {
             if (array_key_exists("debug", $assoc_args)) {
                 $this->_debug(get_defined_vars());
             }
             Terminus::line("Logged in as " . $data['email']);
             Terminus::launch_self("art", array("fist"));
         } else {
             Terminus::error("Login Failed!");
         }
         return;
     }
     # 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 (\Terminus\Utils\is_valid_email($email)) {
         if (!isset($assoc_args['password'])) {
             exec("stty -echo");
             $password = Terminus::prompt("Your dashboard password (input will not be shown)");
             exec("stty echo");
             Terminus::line();
         } else {
             $password = $assoc_args['password'];
         }
         Terminus::line("Logging in as {$email}");
         $data = $this->doLogin($email, $password);
         if ($data != FALSE) {
             if (array_key_exists("debug", $assoc_args)) {
                 $this->_debug(get_defined_vars());
             }
             Terminus::launch_self("art", array("fist"));
         } else {
             Terminus::error("Login Failed!");
         }
     } else {
         Terminus::error("Error: invalid email address");
     }
 }