From 7a60e17367888664a98ef8896f23e270f0e9a59b Mon Sep 17 00:00:00 2001 From: Roly Rudy Gutierrez Pinto Date: Mon, 8 May 2017 15:22:46 -0400 Subject: [PATCH] HOR-1750 --- .../Policies/ControlUnderUpdating.php | 38 ++++++++++++------- .../ProcessMaker/Services/OAuth2/Server.php | 2 + 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/workflow/engine/src/ProcessMaker/Policies/ControlUnderUpdating.php b/workflow/engine/src/ProcessMaker/Policies/ControlUnderUpdating.php index 5247f160f..c40363912 100644 --- a/workflow/engine/src/ProcessMaker/Policies/ControlUnderUpdating.php +++ b/workflow/engine/src/ProcessMaker/Policies/ControlUnderUpdating.php @@ -23,20 +23,7 @@ class ControlUnderUpdating implements iAuthenticate public function __isAllowed() { $response = true; - $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); - } - } + self::verifyUnderUpgrading(); return $response; } @@ -53,4 +40,27 @@ class ControlUnderUpdating implements iAuthenticate 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); + } + } + } + } diff --git a/workflow/engine/src/ProcessMaker/Services/OAuth2/Server.php b/workflow/engine/src/ProcessMaker/Services/OAuth2/Server.php index 4e1563fc9..1e7c77f8c 100644 --- a/workflow/engine/src/ProcessMaker/Services/OAuth2/Server.php +++ b/workflow/engine/src/ProcessMaker/Services/OAuth2/Server.php @@ -284,6 +284,8 @@ class Server implements iAuthenticate */ 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 if ($request == null) { $request = \OAuth2\Request::createFromGlobals();