-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modification to import process to (a) allow creating a site from and …
…import and (b) ensure wordpress import are not improperly tagged as drush archives. Also removes a deprecated function and fixes some spacing in the auth command.
- Loading branch information
1 parent
e71d962
commit 934340b
Showing
6 changed files
with
124 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,40 +29,40 @@ class Auth_Command extends Terminus_Command { | |
* : dump call information when logging in. | ||
*/ | ||
public function login( $args, $assoc_args ) { | ||
if ( empty( $args ) ) { | ||
$email = Terminus::prompt( "Your email address?", NULL ); | ||
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 { | ||
$email = $args[0]; | ||
$password = $assoc_args['password']; | ||
} | ||
Terminus::line( "Logging in as $email" ); | ||
$data = $this->doLogin($email, $password); | ||
|
||
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::line( "Success!" ); | ||
Terminus::launch_self("art", array("fist")); | ||
} | ||
else { | ||
Terminus::error( "Login Failed!" ); | ||
if ( $data != FALSE ) { | ||
if (array_key_exists("debug", $assoc_args)){ | ||
$this->_debug(get_defined_vars()); | ||
} | ||
//Terminus::line( "Success!" ); | ||
Terminus::launch_self("art", array("fist")); | ||
} | ||
else { | ||
Terminus::error( "Error: invalid email address" ); | ||
Terminus::error( "Login Failed!" ); | ||
} | ||
} | ||
else { | ||
Terminus::error( "Error: invalid email address" ); | ||
} | ||
} | ||
|
||
/** | ||
|
@@ -112,58 +112,39 @@ private function _checkSession() { | |
*/ | ||
private function doLogin($email,$password) | ||
{ | ||
if (Terminus::is_test()) { | ||
$data = array( | ||
'user_uuid' => '77629472-3050-457c-8c3d-32b2cabf992b', | ||
'session' => '77629472-3050-457c-8c3d-32b2cabf992b:7dc42f40-65f8-11e4-b314-bc764e100eb1:ZHR0TgtQYsKcOOwMOd0tk', | ||
'session_expire_time' => '1417727066', | ||
'email' => '[email protected]', | ||
); | ||
return $data; | ||
} | ||
|
||
$options = array( | ||
'body' => json_encode(array( | ||
'email' => $email, | ||
'password' => $password, | ||
)), | ||
'headers' => array('Content-type'=>'application/json'), | ||
); | ||
|
||
$response = Terminus_Command::request('login','','','POST',$options); | ||
if ( !$response OR '200' != @$response['info']['http_code'] ) { | ||
\Terminus::error("[auth_error]: unsuccessful login"); | ||
} | ||
|
||
// Prepare credentials for storage. | ||
if (Terminus::is_test()) { | ||
$data = array( | ||
'user_uuid' => $response['data']->user_id, | ||
'session' => $response['data']->session, | ||
'session_expire_time' => $response['data']->expires_at, | ||
'email' => $email, | ||
'user_uuid' => '77629472-3050-457c-8c3d-32b2cabf992b', | ||
'session' => '77629472-3050-457c-8c3d-32b2cabf992b:7dc42f40-65f8-11e4-b314-bc764e100eb1:ZHR0TgtQYsKcOOwMOd0tk', | ||
'session_expire_time' => '1417727066', | ||
'email' => '[email protected]', | ||
); | ||
// creates a session instance | ||
Session::instance()->setData($data); | ||
return $data; | ||
} | ||
|
||
public function getUUIDFromSession() { | ||
if( !$this->session ) { | ||
throw new Exception("Need a valid session."); | ||
} | ||
|
||
$endpoint = sprintf("https://%s/api/user",TERMINUS_HOST); | ||
$response = Request::send($endpoint, "GET", array( | ||
'allow_redirects'=>true, | ||
'cookies'=> | ||
array('X-Pantheon-Session'=>$this->session) | ||
) | ||
$options = array( | ||
'body' => json_encode(array( | ||
'email' => $email, | ||
'password' => $password, | ||
)), | ||
'headers' => array('Content-type'=>'application/json'), | ||
); | ||
|
||
$user = json_decode($response->getBody(TRUE)); | ||
$this->cache->put_data("user",$user); | ||
return $user->id; | ||
$response = Terminus_Command::request('login','','','POST',$options); | ||
if ( !$response OR '200' != @$response['info']['http_code'] ) { | ||
\Terminus::error("[auth_error]: unsuccessful login"); | ||
} | ||
|
||
// Prepare credentials for storage. | ||
$data = array( | ||
'user_uuid' => $response['data']->user_id, | ||
'session' => $response['data']->session, | ||
'session_expire_time' => $response['data']->expires_at, | ||
'email' => $email, | ||
); | ||
// creates a session instance | ||
Session::instance()->setData($data); | ||
return $data; | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters