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