Merge pull request #9111 from nextcloud/use-proper-bool-user-disabled-state
Return proper boolean and do not save enabled state in db
This commit is contained in:
commit
acbcc607ea
|
@ -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()) {
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -816,7 +816,7 @@ class UserTest extends TestCase {
|
|||
->method('triggerChange')
|
||||
->with(
|
||||
'enabled',
|
||||
'false'
|
||||
false
|
||||
);
|
||||
|
||||
$user->setEnabled(false);
|
||||
|
|
Loading…
Reference in New Issue