From eae55761de914f47136e06bafd99898061080a08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Fri, 6 Apr 2018 20:19:52 +0200 Subject: [PATCH 1/2] Properly return boolean on enable state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- apps/provisioning_api/lib/Controller/AUserData.php | 2 +- lib/private/User/User.php | 5 ++--- lib/public/IUser.php | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/provisioning_api/lib/Controller/AUserData.php b/apps/provisioning_api/lib/Controller/AUserData.php index 82ca98ced8..6c4967a6c3 100644 --- a/apps/provisioning_api/lib/Controller/AUserData.php +++ b/apps/provisioning_api/lib/Controller/AUserData.php @@ -92,7 +92,7 @@ abstract class AUserData extends OCSController { // Should be at least Admin Or SubAdmin! if( $this->groupManager->isAdmin($currentLoggedInUser->getUID()) || $this->groupManager->getSubAdmin()->isUserAccessible($currentLoggedInUser, $targetUserObject)) { - $data['enabled'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'enabled', 'true'); + $data['enabled'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'enabled', 'true') === 'true'; } else { // Check they are looking up themselves if($currentLoggedInUser->getUID() !== $targetUserObject->getUID()) { diff --git a/lib/private/User/User.php b/lib/private/User/User.php index 56c489181d..e171a65f8c 100644 --- a/lib/private/User/User.php +++ b/lib/private/User/User.php @@ -349,13 +349,12 @@ class User implements IUser { * * @param bool $enabled */ - public function setEnabled($enabled) { + public function setEnabled(bool $enabled = true) { $oldStatus = $this->isEnabled(); $this->enabled = $enabled; - $enabled = $enabled ? 'true' : 'false'; if ($oldStatus !== $this->enabled) { $this->triggerChange('enabled', $enabled); - $this->config->setUserValue($this->uid, 'core', 'enabled', $enabled); + $this->config->setUserValue($this->uid, 'core', 'enabled', $enabled ? 'true' : 'false'); } } diff --git a/lib/public/IUser.php b/lib/public/IUser.php index 13aa60b380..3d8515a5e0 100644 --- a/lib/public/IUser.php +++ b/lib/public/IUser.php @@ -146,7 +146,7 @@ interface IUser { * @param bool $enabled * @since 8.0.0 */ - public function setEnabled($enabled); + public function setEnabled(bool $enabled = true); /** * get the users email address From 8b9bd37e4ed566adf6e20262280599108bb57c14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Mon, 9 Apr 2018 11:31:41 +0200 Subject: [PATCH 2/2] Fixed tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- .../provisioning_api/tests/Controller/UsersControllerTest.php | 4 ++-- tests/lib/User/UserTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php index 3d6ab8f3eb..148879d6d9 100644 --- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php +++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php @@ -766,7 +766,7 @@ class UsersControllerTest extends TestCase { $expected = [ 'id' => 'UID', - 'enabled' => 'true', + 'enabled' => true, 'storageLocation' => '/var/www/newtcloud/data/UID', 'lastLogin' => 1521191471000, 'backend' => 'Database', @@ -881,7 +881,7 @@ class UsersControllerTest extends TestCase { $expected = [ 'id' => 'UID', - 'enabled' => 'true', + 'enabled' => true, 'storageLocation' => '/var/www/newtcloud/data/UID', 'lastLogin' => 1521191471000, 'backend' => 'Database', diff --git a/tests/lib/User/UserTest.php b/tests/lib/User/UserTest.php index acb171d92e..2a99e725ec 100644 --- a/tests/lib/User/UserTest.php +++ b/tests/lib/User/UserTest.php @@ -816,7 +816,7 @@ class UserTest extends TestCase { ->method('triggerChange') ->with( 'enabled', - 'false' + false ); $user->setEnabled(false);