From 96f419a39af43a98842255aa1300b4b23bed7a8d Mon Sep 17 00:00:00 2001 From: Taras Machyshyn Date: Mon, 25 Nov 2013 13:45:16 +0200 Subject: [PATCH] isAdmin fixes --- application/Espo/Controllers/Settings.php | 23 +++-------------------- application/Espo/Core/Utils/Api/Auth.php | 1 + 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/application/Espo/Controllers/Settings.php b/application/Espo/Controllers/Settings.php index 8f3ba534c3..b75c8ab7bf 100644 --- a/application/Espo/Controllers/Settings.php +++ b/application/Espo/Controllers/Settings.php @@ -9,32 +9,15 @@ class Settings extends \Espo\Core\Controllers\Base public function actionRead($params, $data) { - $admin = false; - if ($this->getUser() instanceof \Espo\Entities\User) { - $admin = $this->getUser()->isAdmin(); - } - - return $this->getConfig()->getJsonData($admin); - //return $this->getConfig()->getJsonData($this->getUser()->isAdmin()); + return $this->getConfig()->getJsonData($this->getUser()->isAdmin()); } public function actionPatch($params, $data) { - $admin = false; - if ($this->getUser() instanceof \Espo\Entities\User) { - $admin = $this->getUser()->isAdmin(); - } - - $result = $this->getConfig()->setJsonData($data, $admin); + $result = $this->getConfig()->setJsonData($data, $this->getUser()->isAdmin()); if ($result === false) { throw new Error('Cannot save settings'); } - return $this->getConfig()->getJsonData($admin); - - /*$result = $this->getConfig()->setJsonData($data, $this->getUser()->isAdmin()); - if ($result === false) { - throw new Error('Cannot save settings'); - } - return $this->getConfig()->getJsonData($this->getUser()->isAdmin());*/ + return $this->getConfig()->getJsonData($this->getUser()->isAdmin()); } } diff --git a/application/Espo/Core/Utils/Api/Auth.php b/application/Espo/Core/Utils/Api/Auth.php index 55a512998c..f66e82a07c 100644 --- a/application/Espo/Core/Utils/Api/Auth.php +++ b/application/Espo/Core/Utils/Api/Auth.php @@ -32,6 +32,7 @@ class Auth extends \Slim\Middleware if (!empty($routes[0])) { $routeConditions = $routes[0]->getConditions(); if (isset($routeConditions['auth']) && $routeConditions['auth'] === false) { + $this->container->setUser(new \Espo\Entities\User()); $this->next->call(); return; }