Restricted some jobs from public execution
This commit is contained in:
parent
9e756e28e4
commit
9f99ccd78f
6 changed files with 21 additions and 0 deletions
|
@ -17,6 +17,11 @@ abstract class AbstractJob implements IJob
|
||||||
|
|
||||||
public abstract function getRequiredArguments();
|
public abstract function getRequiredArguments();
|
||||||
|
|
||||||
|
public function isAvailableToPublic()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
$name = get_called_class();
|
$name = get_called_class();
|
||||||
|
|
|
@ -9,6 +9,7 @@ interface IJob
|
||||||
public function getRequiredSubPrivileges();
|
public function getRequiredSubPrivileges();
|
||||||
public function isAuthenticationRequired();
|
public function isAuthenticationRequired();
|
||||||
public function isConfirmedEmailRequired();
|
public function isConfirmedEmailRequired();
|
||||||
|
public function isAvailableToPublic();
|
||||||
|
|
||||||
public function getArgument($key);
|
public function getArgument($key);
|
||||||
public function getArguments();
|
public function getArguments();
|
||||||
|
|
|
@ -72,6 +72,11 @@ class ActivateUserEmailJob extends AbstractJob
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isAvailableToPublic()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static function sendEmail($user)
|
public static function sendEmail($user)
|
||||||
{
|
{
|
||||||
$regConfig = Core::getConfig()->registration;
|
$regConfig = Core::getConfig()->registration;
|
||||||
|
|
|
@ -76,6 +76,11 @@ class PasswordResetJob extends AbstractJob
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isAvailableToPublic()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static function sendEmail($user)
|
public static function sendEmail($user)
|
||||||
{
|
{
|
||||||
$regConfig = Core::getConfig()->registration;
|
$regConfig = Core::getConfig()->registration;
|
||||||
|
|
|
@ -22,6 +22,8 @@ class ApiController extends AbstractController
|
||||||
$job = $this->jobFromName($jobName);
|
$job = $this->jobFromName($jobName);
|
||||||
if (!$job)
|
if (!$job)
|
||||||
throw new SimpleException('Unknown job: ' . $jobName);
|
throw new SimpleException('Unknown job: ' . $jobName);
|
||||||
|
if (!$job->isAvailableToPublic())
|
||||||
|
throw new SimpleException('This job is unavailable for public.');
|
||||||
|
|
||||||
if (isset($_FILES['args']))
|
if (isset($_FILES['args']))
|
||||||
{
|
{
|
||||||
|
|
|
@ -108,6 +108,9 @@ $jobClassNames = array_values($jobClassNames);
|
||||||
foreach ($jobClassNames as $i => $className)
|
foreach ($jobClassNames as $i => $className)
|
||||||
{
|
{
|
||||||
$job = new $className;
|
$job = new $className;
|
||||||
|
if (!$job->isAvailableToPublic())
|
||||||
|
continue;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php if ($i != 0): ?>
|
<?php if ($i != 0): ?>
|
||||||
|
|
Loading…
Reference in a new issue