add new exception
This commit is contained in:
@@ -25,6 +25,9 @@
|
|||||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use ProcessMaker\Exception\RBACException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File: $Id$
|
* File: $Id$
|
||||||
*
|
*
|
||||||
@@ -1545,8 +1548,7 @@ class RBAC
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$access) {
|
if (!$access) {
|
||||||
G::header('Location: /errors/error403.php');
|
throw new RBACException('ID_ACCESS_DENIED', 403);
|
||||||
die();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use ProcessMaker\Exception\RBACException;
|
||||||
|
|
||||||
$req = (isset($_POST['request']))? $_POST['request']:((isset($_REQUEST['request']))? $_REQUEST['request'] : 'No hayyy tal');
|
$req = (isset($_POST['request']))? $_POST['request']:((isset($_REQUEST['request']))? $_REQUEST['request'] : 'No hayyy tal');
|
||||||
|
|
||||||
require_once 'classes/model/Content.php';
|
require_once 'classes/model/Content.php';
|
||||||
@@ -10,14 +13,10 @@ require_once 'classes/model/Application.php';
|
|||||||
global $RBAC;
|
global $RBAC;
|
||||||
switch ($RBAC->userCanAccess('PM_LOGIN')) {
|
switch ($RBAC->userCanAccess('PM_LOGIN')) {
|
||||||
case -2:
|
case -2:
|
||||||
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels');
|
throw new RBACException('ID_USER_HAVENT_RIGHTS_SYSTEM', -2);
|
||||||
G::header('location: ../login/login');
|
|
||||||
die();
|
|
||||||
break;
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
|
throw new RBACException('ID_USER_HAVENT_RIGHTS_PAGE', -1);
|
||||||
G::header('location: ../login/login');
|
|
||||||
die();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$RBAC->allows(basename(__FILE__), $req);
|
$RBAC->allows(basename(__FILE__), $req);
|
||||||
|
|||||||
59
workflow/engine/src/ProcessMaker/Exception/RBACException.php
Normal file
59
workflow/engine/src/ProcessMaker/Exception/RBACException.php
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace ProcessMaker\Exception;
|
||||||
|
|
||||||
|
use G;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class PMException
|
||||||
|
* @package ProcessMaker\Exception
|
||||||
|
*/
|
||||||
|
class RBACException extends \Exception
|
||||||
|
{
|
||||||
|
const PM_LOGIN = '../login/login';
|
||||||
|
const PM_403 = '/errors/error403.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RBACException constructor.
|
||||||
|
* @param string $message
|
||||||
|
* @param null $code
|
||||||
|
*/
|
||||||
|
public function __construct($message, $code=NULL)
|
||||||
|
{
|
||||||
|
parent::__construct($message, $code);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays the entire exception as a string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function __toString()
|
||||||
|
{
|
||||||
|
switch ($this->getCode()) {
|
||||||
|
case -1:
|
||||||
|
G::SendTemporalMessage($this->getMessage(), 'error', 'labels');
|
||||||
|
$message = self::PM_LOGIN;
|
||||||
|
break;
|
||||||
|
case -2:
|
||||||
|
G::SendTemporalMessage($this->getMessage(), 'error', 'labels');
|
||||||
|
$message = self::PM_LOGIN;
|
||||||
|
break;
|
||||||
|
case 403:
|
||||||
|
$message = self::PM_403;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$message = self::PM_LOGIN;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return $message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the path to which to redirect
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function getPath()
|
||||||
|
{
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -53,6 +53,8 @@ try {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} catch (ProcessMaker\Exception\RBACException $e) {
|
||||||
|
G::header('location: ' . $e->getPath());
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$view = new Maveriks\Pattern\Mvc\PhtmlView($rootDir . "framework/src/templates/Exception.phtml");
|
$view = new Maveriks\Pattern\Mvc\PhtmlView($rootDir . "framework/src/templates/Exception.phtml");
|
||||||
$view->set("message", $e->getMessage());
|
$view->set("message", $e->getMessage());
|
||||||
|
|||||||
Reference in New Issue
Block a user