Skip to content

Commit

Permalink
fix region on Auth initilization
Browse files Browse the repository at this point in the history
  • Loading branch information
waylandzhang committed Dec 23, 2016
1 parent 2c18fc3 commit 4d03dee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
14 changes: 6 additions & 8 deletions src/K5/Token/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ class Auth
public $username;
public $password;
public $contract;
public $global;
public $region;

// if client side stored $token_passed is passed in, we just return it without making the request
public function __construct($username, $password, $contract, $global = false, $token_passed = false) {
public function __construct($username, $password, $contract, $region = '', $token_passed = false) {
$this->username = $username;
$this->password = $password;
$this->contract = $contract;
$this->global = $global;
$this->region = $region;
$this->token_passed = $token_passed;
}

Expand All @@ -41,19 +41,17 @@ public function __construct($username, $password, $contract, $global = false, $t
*
* @return array
*/
public function getAuthToken($region = '')
public function getAuthToken()
{

if($token_passed){
return $token_passed;
}

empty($region) ? $gls = '' : $gls = $region . '.';

$this->global ? $gls = 'gls.' : $gls = '';
!empty($this->region) ? $region = $this->region . '.' : $region = '';

$c = '\
curl -i -X "POST" "https://identity.'.$gls.'cloud.global.fujitsu.com/v3/auth/tokens" \
curl -i -X "POST" "https://identity.'.$region.'cloud.global.fujitsu.com/v3/auth/tokens" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d \'{
Expand Down
4 changes: 2 additions & 2 deletions src/K5/Token/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace K5\Token;


class User
class User extends Auth
{


Expand All @@ -12,7 +12,7 @@ public function getUserProjects($region, $user_id){
$Auth = Auth::getAuthToken();

$c = '\
curl -X GET https://identity.' .$region. '.cloud.global.fujitsu.com/v3/users/'. $user_id. ' \
curl -X GET https://identity.' .$region. '.cloud.global.fujitsu.com/v3/users/' . $user_id . '/projects \
-H "Content-Type: application/json" \
-H "X-Auth-Token: '. $Auth['token'] .'" \
';
Expand Down

0 comments on commit 4d03dee

Please sign in to comment.