GI-150 Borrar el endpoint gmailIntegration/token
This commit is contained in:
@@ -25,75 +25,6 @@ class Pmgmail {
|
|||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Post Token by usrGmail
|
|
||||||
*
|
|
||||||
* @param string $request_data
|
|
||||||
*
|
|
||||||
* return token
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function postTokenbyEmail($request_data)
|
|
||||||
{
|
|
||||||
//Lets verify the gmail token
|
|
||||||
$url = 'https://www.googleapis.com/oauth2/v1/tokeninfo?access_token='.$request_data['token'];
|
|
||||||
|
|
||||||
// init curl object
|
|
||||||
$ch = curl_init();
|
|
||||||
// define options
|
|
||||||
$optArray = array(
|
|
||||||
CURLOPT_URL => $url,
|
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
|
||||||
CURLOPT_SSL_VERIFYPEER => false
|
|
||||||
);
|
|
||||||
// apply those options
|
|
||||||
curl_setopt_array($ch, $optArray);
|
|
||||||
// execute request and get response
|
|
||||||
$result = curl_exec($ch);
|
|
||||||
$response = (json_decode($result));
|
|
||||||
// Check if any error occurred
|
|
||||||
if(curl_errno($ch))
|
|
||||||
{
|
|
||||||
throw (new \Exception('The url is not valid.'));
|
|
||||||
}
|
|
||||||
$info = curl_getinfo($ch);
|
|
||||||
curl_close($ch);
|
|
||||||
|
|
||||||
//If there is response
|
|
||||||
if($info['http_code'] == 200 && isset($response->email)){
|
|
||||||
//If the usermail that was send in the end point es the same of the one in the response
|
|
||||||
if($request_data['mail'] == $response->email){
|
|
||||||
$oUsers = new \Users();
|
|
||||||
$userExist = $oUsers->loadByUserEmailInArray($request_data['mail']);
|
|
||||||
if(count($userExist) == 1){
|
|
||||||
if($userExist['0']['USR_STATUS'] == "ACTIVE"){
|
|
||||||
//User Active! lets create the token and register it in the DB for this user
|
|
||||||
$oauthServer = new \ProcessMaker\Services\OAuth2\Server;
|
|
||||||
$server = $oauthServer->getServer();
|
|
||||||
$config = array(
|
|
||||||
'allow_implicit' => $server->getConfig('allow_implicit'),
|
|
||||||
'access_lifetime' => $server->getConfig('access_lifetime')
|
|
||||||
);
|
|
||||||
$storage = $server->getStorages();
|
|
||||||
$accessToken = new \OAuth2\ResponseType\AccessToken($storage['access_token'],$storage['refresh_token'],$config);
|
|
||||||
$token = $accessToken->createAccessToken($request_data['clientid'], $userExist['0']['USR_UID'],$request_data['scope']);
|
|
||||||
}else {
|
|
||||||
throw (new \Exception('The user is not ACTIVE!'));
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
throw (new \Exception('This email is assigned to more than one user. Please contact your administrator.'));
|
|
||||||
die;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw (new \Exception('The email does not corresponds to the token gmail user.'));
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
throw (new \Exception('The gmail token is not valid.'));
|
|
||||||
}
|
|
||||||
return $token;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Application data by appUid
|
* Get Application data by appUid
|
||||||
*
|
*
|
||||||
@@ -105,32 +36,32 @@ class Pmgmail {
|
|||||||
*/
|
*/
|
||||||
public function getDraftApp($app_uid, $index=1)
|
public function getDraftApp($app_uid, $index=1)
|
||||||
{
|
{
|
||||||
$c = new \Criteria( 'workflow' );
|
$c = new \Criteria( 'workflow' );
|
||||||
|
|
||||||
$c->clearSelectColumns();
|
$c->clearSelectColumns();
|
||||||
$c->addSelectColumn( \AppCacheViewPeer::APP_NUMBER );
|
$c->addSelectColumn( \AppCacheViewPeer::APP_NUMBER );
|
||||||
$c->addSelectColumn( \AppCacheViewPeer::APP_STATUS );
|
$c->addSelectColumn( \AppCacheViewPeer::APP_STATUS );
|
||||||
$c->addSelectColumn( \AppCacheViewPeer::DEL_INDEX );
|
$c->addSelectColumn( \AppCacheViewPeer::DEL_INDEX );
|
||||||
$c->addSelectColumn( \AppCacheViewPeer::APP_DEL_PREVIOUS_USER );
|
$c->addSelectColumn( \AppCacheViewPeer::APP_DEL_PREVIOUS_USER );
|
||||||
$c->addSelectColumn( \AppCacheViewPeer::DEL_DELEGATE_DATE );
|
$c->addSelectColumn( \AppCacheViewPeer::DEL_DELEGATE_DATE );
|
||||||
$c->addSelectColumn( \AppCacheViewPeer::USR_UID );
|
$c->addSelectColumn( \AppCacheViewPeer::USR_UID );
|
||||||
$c->addSelectColumn( \AppCacheViewPeer::PRO_UID );
|
$c->addSelectColumn( \AppCacheViewPeer::PRO_UID );
|
||||||
$c->addSelectColumn( \AppCacheViewPeer::APP_PRO_TITLE );
|
$c->addSelectColumn( \AppCacheViewPeer::APP_PRO_TITLE );
|
||||||
$c->addSelectColumn( \AppCacheViewPeer::APP_TAS_TITLE );
|
$c->addSelectColumn( \AppCacheViewPeer::APP_TAS_TITLE );
|
||||||
$c->addSelectColumn( \AppCacheViewPeer::DEL_THREAD_STATUS );
|
$c->addSelectColumn( \AppCacheViewPeer::DEL_THREAD_STATUS );
|
||||||
$c->addSelectColumn( \AppCacheViewPeer::TAS_UID );
|
$c->addSelectColumn( \AppCacheViewPeer::TAS_UID );
|
||||||
$c->addSelectColumn( \AppCacheViewPeer::DEL_LAST_INDEX );
|
$c->addSelectColumn( \AppCacheViewPeer::DEL_LAST_INDEX );
|
||||||
|
|
||||||
$c->add( \AppCacheViewPeer::APP_UID, $app_uid );
|
$c->add( \AppCacheViewPeer::APP_UID, $app_uid );
|
||||||
$c->add( \AppCacheViewPeer::DEL_INDEX, $index );
|
$c->add( \AppCacheViewPeer::DEL_INDEX, $index );
|
||||||
|
|
||||||
$rs = \AppCacheViewPeer::doSelectRS( $c );
|
$rs = \AppCacheViewPeer::doSelectRS( $c );
|
||||||
$rs->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
|
$rs->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
|
||||||
|
|
||||||
$rows = Array ();
|
$rows = Array ();
|
||||||
while ($rs->next()) {
|
while ($rs->next()) {
|
||||||
$rows[] = $rs->getRow();
|
$rows[] = $rs->getRow();
|
||||||
}
|
}
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ProcessMaker\Services\Api;
|
|
||||||
|
|
||||||
use \ProcessMaker\Services\Api;
|
|
||||||
use \Luracast\Restler\RestException;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GmailIntegration Api Controller
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @hybrid
|
|
||||||
*/
|
|
||||||
class GmailToken extends Api
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Get token by usr_gmail
|
|
||||||
*
|
|
||||||
* @param array $request_data
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @url POST /token
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function doPostAuthenticationbyEmail ($request_data){
|
|
||||||
try{
|
|
||||||
$Pmgmail = new \ProcessMaker\BusinessModel\Pmgmail();
|
|
||||||
$response = $Pmgmail->postTokenbyEmail($request_data);
|
|
||||||
return $response;
|
|
||||||
} catch (\Exception $e){
|
|
||||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user