Prevent triggering a function off of a function
This commit is contained in:
parent
02cd8720f7
commit
2ee7a3a356
1 changed files with 12 additions and 1 deletions
|
@ -7,6 +7,11 @@ use Utopia\Validator;
|
||||||
|
|
||||||
class Event extends Validator
|
class Event extends Validator
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected string $message = 'Event is not valid.';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Description.
|
* Get Description.
|
||||||
*
|
*
|
||||||
|
@ -16,7 +21,7 @@ class Event extends Validator
|
||||||
*/
|
*/
|
||||||
public function getDescription(): string
|
public function getDescription(): string
|
||||||
{
|
{
|
||||||
return 'Event is not valid.';
|
return $this->message;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,6 +45,12 @@ class Event extends Validator
|
||||||
* Identify all sections of the pattern.
|
* Identify all sections of the pattern.
|
||||||
*/
|
*/
|
||||||
$type = $parts[0] ?? false;
|
$type = $parts[0] ?? false;
|
||||||
|
|
||||||
|
if ($type == 'functions') {
|
||||||
|
$this->message = 'Triggering a function on a function event is not allowed.';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$resource = $parts[1] ?? false;
|
$resource = $parts[1] ?? false;
|
||||||
$hasSubResource = $count > 3 && ($events[$type]['$resource'] ?? false) && ($events[$type][$parts[2]]['$resource'] ?? false);
|
$hasSubResource = $count > 3 && ($events[$type]['$resource'] ?? false) && ($events[$type][$parts[2]]['$resource'] ?? false);
|
||||||
$hasSubSubResource = $count > 5 && $hasSubResource && ($events[$type][$parts[2]][$parts[4]]['$resource'] ?? false);
|
$hasSubSubResource = $count > 5 && $hasSubResource && ($events[$type][$parts[2]][$parts[4]]['$resource'] ?? false);
|
||||||
|
|
Loading…
Reference in a new issue