cron. first code
This commit is contained in:
@@ -97,6 +97,13 @@ class Application
|
||||
$slim->run();
|
||||
}
|
||||
|
||||
public function runCron()
|
||||
{
|
||||
$auth = $this->getAuth();
|
||||
$auth->useNoAuth();
|
||||
// TODO cron manager
|
||||
}
|
||||
|
||||
protected function routeHooks()
|
||||
{
|
||||
$container = $this->getContainer();
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Espo\Core\Utils;
|
||||
|
||||
use \Espo\Core\Exceptions\Error;
|
||||
|
||||
class Auth
|
||||
{
|
||||
protected $container;
|
||||
@@ -14,7 +16,13 @@ class Auth
|
||||
public function useNoAuth()
|
||||
{
|
||||
$entityManager = $this->container->get('entityManager');
|
||||
$this->container->setUser($entityManager->getEntity('User'));
|
||||
|
||||
$user = $entityManager->getRepository('User')->get('system');
|
||||
if (!$user) {
|
||||
throw new Error('System user is not found');
|
||||
}
|
||||
|
||||
$this->container->setUser($user);
|
||||
}
|
||||
|
||||
public function login($username, $password)
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
"type": "varchar",
|
||||
"required": true
|
||||
},
|
||||
"lastRun": {
|
||||
"type": "datetime",
|
||||
"readOnly": true
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "datetime",
|
||||
"readOnly": true
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Espo\Services;
|
||||
|
||||
use \Espo\Core\Exceptions\Forbidden;
|
||||
|
||||
class User extends Record
|
||||
{
|
||||
public function getEntity($id)
|
||||
@@ -30,10 +32,21 @@ class User extends Record
|
||||
|
||||
public function updateEntity($id, $data)
|
||||
{
|
||||
if ($id == 'system') {
|
||||
$data['isAdmin'] = true;
|
||||
}
|
||||
if (array_key_exists('password', $data)) {
|
||||
$data['password'] = md5($data['password']);
|
||||
}
|
||||
return parent::updateEntity($id, $data);
|
||||
}
|
||||
|
||||
public function deleteEntity($id)
|
||||
{
|
||||
if ($id == 'system') {
|
||||
throw new Forbidden();
|
||||
}
|
||||
return parent::deleteEntity($id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user