Merged in bugfix/PMCORE-779 (pull request #7223)
PMCORE-779 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
|
||||||
global $RBAC;
|
global $RBAC;
|
||||||
|
|
||||||
$resultRbac = $RBAC->requirePermissions('PM_SETUP_EMAIL');
|
$resultRbac = $RBAC->requirePermissions('PM_SETUP_EMAIL');
|
||||||
@@ -9,6 +11,12 @@ if (!$resultRbac) {
|
|||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$messageSent = "";
|
||||||
|
if (Cache::has('errorMessageIfNotAuthenticate')) {
|
||||||
|
$messageSent = Cache::get('errorMessageIfNotAuthenticate');
|
||||||
|
}
|
||||||
|
Cache::forget('errorMessageIfNotAuthenticate');
|
||||||
|
|
||||||
//Data
|
//Data
|
||||||
$configuration = new Configurations();
|
$configuration = new Configurations();
|
||||||
$arrayConfigPage = $configuration->getConfiguration("emailServerList", "pageSize", null, $_SESSION["USER_LOGGED"]);
|
$arrayConfigPage = $configuration->getConfiguration("emailServerList", "pageSize", null, $_SESSION["USER_LOGGED"]);
|
||||||
@@ -20,6 +28,7 @@ $headPublisher = headPublisher::getSingleton();
|
|||||||
$headPublisher->addContent("emailServer/emailServer"); //Adding a HTML file
|
$headPublisher->addContent("emailServer/emailServer"); //Adding a HTML file
|
||||||
$headPublisher->addExtJsScript("emailServer/emailServer", false); //Adding a JavaScript file
|
$headPublisher->addExtJsScript("emailServer/emailServer", false); //Adding a JavaScript file
|
||||||
$headPublisher->assign("CONFIG", $arrayConfig);
|
$headPublisher->assign("CONFIG", $arrayConfig);
|
||||||
|
$headPublisher->assign("errorMessageIfNotAuthenticate", $messageSent);
|
||||||
|
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
$headPublisher->assign("EMAILSERVER_LICENSED", (PMLicensedFeatures::getSingleton()->verifyfeature("zIKRGpDM3pjcHFsWGplNDN0dTl5bGN3UTNiOWdQU0E5Q05QTksrU1ladWQ0VT0=")) ? 1 : 0);
|
$headPublisher->assign("EMAILSERVER_LICENSED", (PMLicensedFeatures::getSingleton()->verifyfeature("zIKRGpDM3pjcHFsWGplNDN0dTl5bGN3UTNiOWdQU0E5Q05QTksrU1ladWQ0VT0=")) ? 1 : 0);
|
||||||
|
|||||||
@@ -1,26 +1,41 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
use ProcessMaker\Core\System;
|
use ProcessMaker\Core\System;
|
||||||
use ProcessMaker\GmailOAuth\GmailOAuth;
|
use ProcessMaker\GmailOAuth\GmailOAuth;
|
||||||
|
|
||||||
$header = "location:" . System::getServerMainPath() . "/setup/main?s=EMAIL_SERVER";
|
Cache::forget('errorMessageIfNotAuthenticate');
|
||||||
|
try {
|
||||||
|
$header = "location:" . System::getServerMainPath() . "/setup/main?s=EMAIL_SERVER";
|
||||||
|
|
||||||
$validInput = empty($_GET['code']) || empty($_SESSION['gmailOAuth']) || !is_object($_SESSION['gmailOAuth']);
|
$validInput = empty($_GET['code']) || empty($_SESSION['gmailOAuth']) || !is_object($_SESSION['gmailOAuth']);
|
||||||
if ($validInput) {
|
if ($validInput) {
|
||||||
G::header($header);
|
G::header($header);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$RBAC->allows(basename(__FILE__), "code");
|
||||||
|
$gmailOAuth = $_SESSION['gmailOAuth'];
|
||||||
|
|
||||||
|
$googleClient = $gmailOAuth->getGoogleClient();
|
||||||
|
$result = $googleClient->authenticate($_GET['code']);
|
||||||
|
if (isset($result["error"])) {
|
||||||
|
Cache::put('errorMessageIfNotAuthenticate', G::json_decode($result["error"]), 2);
|
||||||
|
G::header($header);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$gmailOAuth->setRefreshToken($googleClient->getRefreshToken());
|
||||||
|
$gmailOAuth->saveEmailServer();
|
||||||
|
$gmailOAuth->sendTestMailWithPHPMailerOAuth();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
/**
|
||||||
|
* The laravel cache is volatile in each session, you can specify the duration
|
||||||
|
* value in minutes for each session. We use 2 minutes, enough time to retrieve
|
||||||
|
* the error message if there is one.
|
||||||
|
*/
|
||||||
|
Cache::put('errorMessageIfNotAuthenticate', $e->getMessage(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
$RBAC->allows(basename(__FILE__), "code");
|
|
||||||
$gmailOAuth = $_SESSION['gmailOAuth'];
|
|
||||||
|
|
||||||
$googleClient = $gmailOAuth->getGoogleClient();
|
|
||||||
$result = $googleClient->authenticate($_GET['code']);
|
|
||||||
if (isset($result["error"])) {
|
|
||||||
G::header($header);
|
|
||||||
}
|
|
||||||
|
|
||||||
$gmailOAuth->setRefreshToken($googleClient->getRefreshToken());
|
|
||||||
$gmailOAuth->saveEmailServer();
|
|
||||||
$gmailOAuth->sendTestMailWithPHPMailerOAuth();
|
|
||||||
|
|
||||||
G::header($header);
|
G::header($header);
|
||||||
|
exit();
|
||||||
|
|||||||
@@ -1283,6 +1283,10 @@ emailServer.application = {
|
|||||||
autoScroll: false,
|
autoScroll: false,
|
||||||
items: [grdpnlMain]
|
items: [grdpnlMain]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (errorMessageIfNotAuthenticate && errorMessageIfNotAuthenticate !== "") {
|
||||||
|
Ext.MessageBox.alert(_("ID_INVALID_DATA"), errorMessageIfNotAuthenticate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user