do not offer to change display name or password, if not possible.
Fixes #12319 Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
836ba4f419
commit
505722cc0d
|
@ -22,6 +22,7 @@ declare(strict_types=1);
|
||||||
namespace OCA\Provisioning_API\Controller;
|
namespace OCA\Provisioning_API\Controller;
|
||||||
|
|
||||||
use OC\Accounts\AccountManager;
|
use OC\Accounts\AccountManager;
|
||||||
|
use OC\User\Backend;
|
||||||
use OCP\AppFramework\OCS\OCSException;
|
use OCP\AppFramework\OCS\OCSException;
|
||||||
use OCP\AppFramework\OCS\OCSNotFoundException;
|
use OCP\AppFramework\OCS\OCSNotFoundException;
|
||||||
use OCP\AppFramework\OCSController;
|
use OCP\AppFramework\OCSController;
|
||||||
|
@ -32,6 +33,8 @@ use OCP\IGroupManager;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
use OCP\IUserManager;
|
use OCP\IUserManager;
|
||||||
use OCP\IUserSession;
|
use OCP\IUserSession;
|
||||||
|
use OCP\User\Backend\ISetDisplayNameBackend;
|
||||||
|
use OCP\User\Backend\ISetPasswordBackend;
|
||||||
|
|
||||||
abstract class AUserData extends OCSController {
|
abstract class AUserData extends OCSController {
|
||||||
|
|
||||||
|
@ -125,6 +128,12 @@ abstract class AUserData extends OCSController {
|
||||||
$data['language'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'lang');
|
$data['language'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'lang');
|
||||||
$data['locale'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'locale');
|
$data['locale'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'locale');
|
||||||
|
|
||||||
|
$backend = $targetUserObject->getBackend();
|
||||||
|
$data['backendCapabilities'] = [
|
||||||
|
'setDisplayName' => $backend instanceof ISetDisplayNameBackend || $backend->implementsActions(Backend::SET_DISPLAYNAME),
|
||||||
|
'setPassword' => $backend instanceof ISetPasswordBackend || $backend->implementsActions(Backend::SET_PASSWORD),
|
||||||
|
];
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,25 +38,22 @@ use OCA\FederatedFileSharing\AppInfo\Application;
|
||||||
use OCA\FederatedFileSharing\FederatedShareProvider;
|
use OCA\FederatedFileSharing\FederatedShareProvider;
|
||||||
use OCA\Provisioning_API\FederatedFileSharingFactory;
|
use OCA\Provisioning_API\FederatedFileSharingFactory;
|
||||||
use OCP\App\IAppManager;
|
use OCP\App\IAppManager;
|
||||||
use OCP\AppFramework\OCS\OCSException;
|
|
||||||
use OCP\Mail\IEMailTemplate;
|
use OCP\Mail\IEMailTemplate;
|
||||||
use OC\Settings\Mailer\NewUserMailHelper;
|
use OC\Settings\Mailer\NewUserMailHelper;
|
||||||
use OC\SubAdmin;
|
use OC\SubAdmin;
|
||||||
use OCA\Provisioning_API\Controller\UsersController;
|
use OCA\Provisioning_API\Controller\UsersController;
|
||||||
use OCP\AppFramework\Http\DataResponse;
|
use OCP\AppFramework\Http\DataResponse;
|
||||||
use OCP\Defaults;
|
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\IGroup;
|
use OCP\IGroup;
|
||||||
use OCP\ILogger;
|
use OCP\ILogger;
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
use OCP\IURLGenerator;
|
|
||||||
use OCP\IUser;
|
use OCP\IUser;
|
||||||
use OCP\IUserManager;
|
use OCP\IUserManager;
|
||||||
use OCP\IUserSession;
|
use OCP\IUserSession;
|
||||||
use OCP\L10N\IFactory;
|
use OCP\L10N\IFactory;
|
||||||
use OCP\Mail\IMailer;
|
|
||||||
use OCP\Security\ISecureRandom;
|
use OCP\Security\ISecureRandom;
|
||||||
|
use OCP\UserInterface;
|
||||||
use PHPUnit_Framework_MockObject_MockObject;
|
use PHPUnit_Framework_MockObject_MockObject;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
|
||||||
|
@ -800,6 +797,12 @@ class UsersControllerTest extends TestCase {
|
||||||
->method('fillStorageInfo')
|
->method('fillStorageInfo')
|
||||||
->with('UID')
|
->with('UID')
|
||||||
->will($this->returnValue(['DummyValue']));
|
->will($this->returnValue(['DummyValue']));
|
||||||
|
|
||||||
|
$backend = $this->createMock(UserInterface::class);
|
||||||
|
$backend->expects($this->any())
|
||||||
|
->method('implementsActions')
|
||||||
|
->willReturn(true);
|
||||||
|
|
||||||
$targetUser
|
$targetUser
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getDisplayName')
|
->method('getDisplayName')
|
||||||
|
@ -816,6 +819,10 @@ class UsersControllerTest extends TestCase {
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getBackendClassName')
|
->method('getBackendClassName')
|
||||||
->will($this->returnValue('Database'));
|
->will($this->returnValue('Database'));
|
||||||
|
$targetUser
|
||||||
|
->expects($this->once())
|
||||||
|
->method('getBackend')
|
||||||
|
->willReturn($backend);
|
||||||
$targetUser
|
$targetUser
|
||||||
->expects($this->exactly(6))
|
->expects($this->exactly(6))
|
||||||
->method('getUID')
|
->method('getUID')
|
||||||
|
@ -838,6 +845,10 @@ class UsersControllerTest extends TestCase {
|
||||||
'groups' => ['group0', 'group1', 'group2'],
|
'groups' => ['group0', 'group1', 'group2'],
|
||||||
'language' => 'de',
|
'language' => 'de',
|
||||||
'locale' => null,
|
'locale' => null,
|
||||||
|
'backendCapabilities' => [
|
||||||
|
'setDisplayName' => true,
|
||||||
|
'setPassword' => true,
|
||||||
|
]
|
||||||
];
|
];
|
||||||
$this->assertEquals($expected, $this->invokePrivate($this->api, 'getUserData', ['UID']));
|
$this->assertEquals($expected, $this->invokePrivate($this->api, 'getUserData', ['UID']));
|
||||||
}
|
}
|
||||||
|
@ -906,6 +917,12 @@ class UsersControllerTest extends TestCase {
|
||||||
->method('fillStorageInfo')
|
->method('fillStorageInfo')
|
||||||
->with('UID')
|
->with('UID')
|
||||||
->will($this->returnValue(['DummyValue']));
|
->will($this->returnValue(['DummyValue']));
|
||||||
|
|
||||||
|
$backend = $this->createMock(UserInterface::class);
|
||||||
|
$backend->expects($this->any())
|
||||||
|
->method('implementsActions')
|
||||||
|
->willReturn(true);
|
||||||
|
|
||||||
$targetUser
|
$targetUser
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getDisplayName')
|
->method('getDisplayName')
|
||||||
|
@ -922,6 +939,10 @@ class UsersControllerTest extends TestCase {
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getBackendClassName')
|
->method('getBackendClassName')
|
||||||
->will($this->returnValue('Database'));
|
->will($this->returnValue('Database'));
|
||||||
|
$targetUser
|
||||||
|
->expects($this->once())
|
||||||
|
->method('getBackend')
|
||||||
|
->willReturn($backend);
|
||||||
$targetUser
|
$targetUser
|
||||||
->expects($this->exactly(6))
|
->expects($this->exactly(6))
|
||||||
->method('getUID')
|
->method('getUID')
|
||||||
|
@ -954,6 +975,10 @@ class UsersControllerTest extends TestCase {
|
||||||
'groups' => [],
|
'groups' => [],
|
||||||
'language' => 'da',
|
'language' => 'da',
|
||||||
'locale' => null,
|
'locale' => null,
|
||||||
|
'backendCapabilities' => [
|
||||||
|
'setDisplayName' => true,
|
||||||
|
'setPassword' => true,
|
||||||
|
]
|
||||||
];
|
];
|
||||||
$this->assertEquals($expected, $this->invokePrivate($this->api, 'getUserData', ['UID']));
|
$this->assertEquals($expected, $this->invokePrivate($this->api, 'getUserData', ['UID']));
|
||||||
}
|
}
|
||||||
|
@ -1054,6 +1079,12 @@ class UsersControllerTest extends TestCase {
|
||||||
->method('fillStorageInfo')
|
->method('fillStorageInfo')
|
||||||
->with('UID')
|
->with('UID')
|
||||||
->will($this->returnValue(['DummyValue']));
|
->will($this->returnValue(['DummyValue']));
|
||||||
|
|
||||||
|
$backend = $this->createMock(UserInterface::class);
|
||||||
|
$backend->expects($this->atLeastOnce())
|
||||||
|
->method('implementsActions')
|
||||||
|
->willReturn(false);
|
||||||
|
|
||||||
$targetUser
|
$targetUser
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getDisplayName')
|
->method('getDisplayName')
|
||||||
|
@ -1078,6 +1109,10 @@ class UsersControllerTest extends TestCase {
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getBackendClassName')
|
->method('getBackendClassName')
|
||||||
->will($this->returnValue('Database'));
|
->will($this->returnValue('Database'));
|
||||||
|
$targetUser
|
||||||
|
->expects($this->once())
|
||||||
|
->method('getBackend')
|
||||||
|
->willReturn($backend);
|
||||||
$this->config
|
$this->config
|
||||||
->expects($this->at(0))
|
->expects($this->at(0))
|
||||||
->method('getUserValue')
|
->method('getUserValue')
|
||||||
|
@ -1110,6 +1145,10 @@ class UsersControllerTest extends TestCase {
|
||||||
'groups' => [],
|
'groups' => [],
|
||||||
'language' => 'ru',
|
'language' => 'ru',
|
||||||
'locale' => null,
|
'locale' => null,
|
||||||
|
'backendCapabilities' => [
|
||||||
|
'setDisplayName' => false,
|
||||||
|
'setPassword' => false,
|
||||||
|
]
|
||||||
];
|
];
|
||||||
$this->assertEquals($expected, $this->invokePrivate($this->api, 'getUserData', ['UID']));
|
$this->assertEquals($expected, $this->invokePrivate($this->api, 'getUserData', ['UID']));
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
|
|
||||||
namespace OCP;
|
namespace OCP;
|
||||||
|
|
||||||
|
use OCP\UserInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface IUser
|
* Interface IUser
|
||||||
*
|
*
|
||||||
|
@ -111,6 +113,7 @@ interface IUser {
|
||||||
/**
|
/**
|
||||||
* Get the backend for the current user object
|
* Get the backend for the current user object
|
||||||
*
|
*
|
||||||
|
* @return UserInterface
|
||||||
* @since 15.0.0
|
* @since 15.0.0
|
||||||
*/
|
*/
|
||||||
public function getBackend();
|
public function getBackend();
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -42,13 +42,17 @@
|
||||||
<!-- dirty hack to ellipsis on two lines -->
|
<!-- dirty hack to ellipsis on two lines -->
|
||||||
<div class="name">{{user.id}}</div>
|
<div class="name">{{user.id}}</div>
|
||||||
<form class="displayName" :class="{'icon-loading-small': loading.displayName}" v-on:submit.prevent="updateDisplayName">
|
<form class="displayName" :class="{'icon-loading-small': loading.displayName}" v-on:submit.prevent="updateDisplayName">
|
||||||
<input :id="'displayName'+user.id+rand" type="text"
|
<template v-if="user.backendCapabilities.setDisplayName">
|
||||||
:disabled="loading.displayName||loading.all"
|
<input v-if="user.backendCapabilities.setDisplayName"
|
||||||
:value="user.displayname" ref="displayName"
|
:id="'displayName'+user.id+rand" type="text"
|
||||||
autocomplete="new-password" autocorrect="off" autocapitalize="off" spellcheck="false" />
|
:disabled="loading.displayName||loading.all"
|
||||||
<input type="submit" class="icon-confirm" value="" />
|
:value="user.displayname" ref="displayName"
|
||||||
|
autocomplete="new-password" autocorrect="off" autocapitalize="off" spellcheck="false" />
|
||||||
|
<input v-if="user.backendCapabilities.setDisplayName" type="submit" class="icon-confirm" value="" />
|
||||||
|
</template>
|
||||||
|
<div v-else class="name" v-tooltip.auto="t('settings', 'The backend does not support changing the display name')">{{user.displayname}}</div>
|
||||||
</form>
|
</form>
|
||||||
<form class="password" v-if="settings.canChangePassword" :class="{'icon-loading-small': loading.password}"
|
<form class="password" v-if="settings.canChangePassword && user.backendCapabilities.setPassword" :class="{'icon-loading-small': loading.password}"
|
||||||
v-on:submit.prevent="updatePassword">
|
v-on:submit.prevent="updatePassword">
|
||||||
<input :id="'password'+user.id+rand" type="password" required
|
<input :id="'password'+user.id+rand" type="password" required
|
||||||
:disabled="loading.password||loading.all" :minlength="minPasswordLength"
|
:disabled="loading.password||loading.all" :minlength="minPasswordLength"
|
||||||
|
|
Loading…
Reference in New Issue