Load Designer JS data update

In javascript section of main file that load Designer UI
for 'var credentials' now we're sending the access token and refresh token, instead access code, and client credentials.

This is just because currently a lot of access tokens were being created for each process design is open, and while it is being open is sending two request, the first one to exchange an access code by an access token,..

Now, whith this change, while a process design is open we will made just one request to some resource with access token in the header,.. exchange access code by an access token is not needed any more.

NOTE.- the access token passed to the front-end can be expired at first time,.. so we need that the exchange an access token by a refresh token handling is working well.
This commit is contained in:
Erik Amaru Ortiz
2014-06-16 18:05:04 -04:00
parent b5dad5386d
commit 03288704bc

View File

@@ -29,16 +29,32 @@ class Designer extends Controller
$client = $this->getClientCredentials();
$authCode = $this->getAuthorizationCode($client);
$loader = Maveriks\Util\ClassLoader::getInstance();
$loader->add(PATH_TRUNK . 'vendor/bshaffer/oauth2-server-php/src/', "OAuth2");
$request = array(
'grant_type' => 'authorization_code',
'code' => $authCode
);
$server = array(
'REQUEST_METHOD' => 'POST'
);
$headers = array(
"PHP_AUTH_USER" => $client['CLIENT_ID'],
"PHP_AUTH_PW" => $client['CLIENT_SECRET'],
"Content-Type" => "multipart/form-data;",
"Authorization" => "Basic " . base64_encode($client['CLIENT_ID'] . ":" . $client['CLIENT_SECRET'])
);
$request = new \OAuth2\Request(array(), $request, array(), array(), array(), $server, null, $headers);
$oauthServer = new \ProcessMaker\Services\OAuth2\Server();
$response = $oauthServer->getServer()->handleTokenRequest($request);
$clientToken = $response->getParameters();
$this->setVar('prj_uid', $proUid);
$this->setVar('app_uid', $appUid);
$this->setVar('prj_readonly', $proReadOnly);
$credentials = array();
$credentials['client_id'] = $client['CLIENT_ID'];
$credentials['secret'] = $client['CLIENT_SECRET'];
$credentials['authorization_code'] = $authCode;
$this->setVar('credentials', base64_encode(json_encode($credentials)));
$this->setVar('credentials', base64_encode(json_encode($clientToken)));
$this->setVar('isDebugMode', System::isDebugMode());
if (System::isDebugMode()) {