Files
luos/workflow/engine/methods/oauth2/authorize.php

34 lines
1.2 KiB
PHP
Raw Normal View History

2013-10-09 13:16:05 -04:00
<?php
switch ($_SERVER['REQUEST_METHOD']) {
case 'GET':
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent( 'view', 'oauth2/authorize' );
G::RenderPage('publish', 'minimal');
break;
case 'POST':
2014-04-21 10:21:01 -04:00
require_once PATH_CORE . 'src/ProcessMaker/Services/OAuth2/Server.php';
2013-10-09 13:16:05 -04:00
list($host, $port) = strpos(DB_HOST, ':') !== false ? explode(':', DB_HOST) : array(DB_HOST, '');
$port = empty($port) ? '' : ";port=$port";
2014-04-21 10:21:01 -04:00
\ProcessMaker\Services\OAuth2\Server::setDatabaseSource(DB_USER, DB_PASS, DB_ADAPTER.":host=$host;dbname=".DB_NAME.$port);
\ProcessMaker\Services\OAuth2\Server::setPmClientId('x-pm-local-client');
2013-10-09 13:16:05 -04:00
2014-04-21 10:21:01 -04:00
$oauthServer = new \ProcessMaker\Services\OAuth2\Server();
2013-10-09 13:16:05 -04:00
$userid = $_SESSION['USER_LOGGED'];
$authorize = isset($_POST['authorize']) ? (bool) $_POST['authorize'] : false;
$response = $oauthServer->postAuthorize($authorize, $userid, true);
2013-10-22 11:17:48 -04:00
//$code = substr($response->getHttpHeader('Location'), strpos($response->getHttpHeader('Location'), 'code=')+5, 40);
2013-10-09 13:16:05 -04:00
2013-10-22 11:17:48 -04:00
//echo 'session_id ' . session_id() . '<br>';
//exit("SUCCESS! ==> Authorization Code: $code");
2013-10-09 13:16:05 -04:00
2013-10-22 11:17:48 -04:00
die($response->send());
2013-10-09 13:16:05 -04:00
break;
}