HOR-1750
This commit is contained in:
@@ -23,20 +23,7 @@ class ControlUnderUpdating implements iAuthenticate
|
|||||||
public function __isAllowed()
|
public function __isAllowed()
|
||||||
{
|
{
|
||||||
$response = true;
|
$response = true;
|
||||||
$underUpdating = \Bootstrap::isPMUnderUpdating();
|
self::verifyUnderUpgrading();
|
||||||
if ($underUpdating['action']) {
|
|
||||||
$sysTemp = true;
|
|
||||||
if (defined('SYS_TEMP')) {
|
|
||||||
$sysTemp = $underUpdating['workspace'] == SYS_TEMP;
|
|
||||||
}
|
|
||||||
if ($underUpdating['workspace'] == 'true' || $sysTemp) {
|
|
||||||
$message = 'The server is currently unable to handle the request '
|
|
||||||
. 'due to temporary overloading or server maintenance ('
|
|
||||||
. 'an application update has probably been performed on '
|
|
||||||
. 'the server)';
|
|
||||||
throw new RestException(503, $message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,4 +40,27 @@ class ControlUnderUpdating implements iAuthenticate
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify under upgrading, if the state is under update an exception is
|
||||||
|
* thrown of type RestException.
|
||||||
|
* @throws RestException
|
||||||
|
*/
|
||||||
|
public static function verifyUnderUpgrading()
|
||||||
|
{
|
||||||
|
$underUpdating = \Bootstrap::isPMUnderUpdating();
|
||||||
|
if ($underUpdating['action']) {
|
||||||
|
$sysTemp = true;
|
||||||
|
if (defined('SYS_TEMP')) {
|
||||||
|
$sysTemp = $underUpdating['workspace'] == SYS_TEMP;
|
||||||
|
}
|
||||||
|
if ($underUpdating['workspace'] == 'true' || $sysTemp) {
|
||||||
|
$message = 'The server is currently unable to handle the request '
|
||||||
|
. 'due to temporary overloading or server maintenance ('
|
||||||
|
. 'an application update has probably been performed on '
|
||||||
|
. 'the server)';
|
||||||
|
throw new RestException(503, $message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -284,6 +284,8 @@ class Server implements iAuthenticate
|
|||||||
*/
|
*/
|
||||||
public function postToken($request = null, $returnResponse = false)
|
public function postToken($request = null, $returnResponse = false)
|
||||||
{
|
{
|
||||||
|
\ProcessMaker\Policies\ControlUnderUpdating::verifyUnderUpgrading();
|
||||||
|
|
||||||
// Handle a request for an OAuth2.0 Access Token and send the response to the client
|
// Handle a request for an OAuth2.0 Access Token and send the response to the client
|
||||||
if ($request == null) {
|
if ($request == null) {
|
||||||
$request = \OAuth2\Request::createFromGlobals();
|
$request = \OAuth2\Request::createFromGlobals();
|
||||||
|
|||||||
Reference in New Issue
Block a user