never translate login names when requiring with a user id
where appropriate, the preLoginNameUsedAsUserName hook should be thrown. Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
c94c2c48a6
commit
776d9e6805
|
@ -223,6 +223,12 @@ class LostController extends Controller {
|
|||
return new JSONResponse($this->error($this->l10n->t('Password reset is disabled')));
|
||||
}
|
||||
|
||||
\OCP\Util::emitHook(
|
||||
'\OCA\Files_Sharing\API\Server2Server',
|
||||
'preLoginNameUsedAsUserName',
|
||||
['uid' => &$user]
|
||||
);
|
||||
|
||||
// FIXME: use HTTP error codes
|
||||
try {
|
||||
$this->sendEmail($user);
|
||||
|
|
|
@ -154,16 +154,6 @@ class Manager extends PublicEmitter implements IUserManager {
|
|||
return $this->cachedUsers[$uid];
|
||||
}
|
||||
|
||||
if (method_exists($backend, 'loginName2UserName')) {
|
||||
$loginName = $backend->loginName2UserName($uid);
|
||||
if ($loginName !== false) {
|
||||
$uid = $loginName;
|
||||
}
|
||||
if (isset($this->cachedUsers[$uid])) {
|
||||
return $this->cachedUsers[$uid];
|
||||
}
|
||||
}
|
||||
|
||||
$user = new User($uid, $backend, $this, $this->config);
|
||||
if ($cacheUser) {
|
||||
$this->cachedUsers[$uid] = $user;
|
||||
|
|
|
@ -184,9 +184,8 @@ class ManagerTest extends TestCase {
|
|||
->method('userExists')
|
||||
->with($this->equalTo('foo'))
|
||||
->will($this->returnValue(true));
|
||||
$backend->expects($this->once())
|
||||
->method('loginName2UserName')
|
||||
->willReturn(false);
|
||||
$backend->expects($this->never())
|
||||
->method('loginName2UserName');
|
||||
|
||||
$manager = new \OC\User\Manager($this->config);
|
||||
$manager->registerBackend($backend);
|
||||
|
@ -210,6 +209,24 @@ class ManagerTest extends TestCase {
|
|||
$this->assertEquals(null, $manager->get('foo'));
|
||||
}
|
||||
|
||||
public function testGetOneBackendDoNotTranslateLoginNames() {
|
||||
/**
|
||||
* @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend
|
||||
*/
|
||||
$backend = $this->createMock(\Test\Util\User\Dummy::class);
|
||||
$backend->expects($this->once())
|
||||
->method('userExists')
|
||||
->with($this->equalTo('bLeNdEr'))
|
||||
->will($this->returnValue(true));
|
||||
$backend->expects($this->never())
|
||||
->method('loginName2UserName');
|
||||
|
||||
$manager = new \OC\User\Manager($this->config);
|
||||
$manager->registerBackend($backend);
|
||||
|
||||
$this->assertEquals('bLeNdEr', $manager->get('bLeNdEr')->getUID());
|
||||
}
|
||||
|
||||
public function testSearchOneBackend() {
|
||||
/**
|
||||
* @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend
|
||||
|
@ -219,6 +236,8 @@ class ManagerTest extends TestCase {
|
|||
->method('getUsers')
|
||||
->with($this->equalTo('fo'))
|
||||
->will($this->returnValue(array('foo', 'afoo')));
|
||||
$backend->expects($this->never())
|
||||
->method('loginName2UserName');
|
||||
|
||||
$manager = new \OC\User\Manager($this->config);
|
||||
$manager->registerBackend($backend);
|
||||
|
@ -238,9 +257,8 @@ class ManagerTest extends TestCase {
|
|||
->method('getUsers')
|
||||
->with($this->equalTo('fo'), $this->equalTo(3), $this->equalTo(1))
|
||||
->will($this->returnValue(array('foo1', 'foo2')));
|
||||
$backend1->expects($this->exactly(2))
|
||||
->method('loginName2UserName')
|
||||
->willReturn(false);
|
||||
$backend1->expects($this->never())
|
||||
->method('loginName2UserName');
|
||||
|
||||
/**
|
||||
* @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend2
|
||||
|
@ -250,9 +268,8 @@ class ManagerTest extends TestCase {
|
|||
->method('getUsers')
|
||||
->with($this->equalTo('fo'), $this->equalTo(3), $this->equalTo(1))
|
||||
->will($this->returnValue(array('foo3')));
|
||||
$backend2->expects($this->once())
|
||||
->method('loginName2UserName')
|
||||
->willReturn(false);
|
||||
$backend2->expects($this->never())
|
||||
->method('loginName2UserName');
|
||||
|
||||
$manager = new \OC\User\Manager($this->config);
|
||||
$manager->registerBackend($backend1);
|
||||
|
@ -333,9 +350,8 @@ class ManagerTest extends TestCase {
|
|||
->method('userExists')
|
||||
->with($this->equalTo('foo'))
|
||||
->will($this->returnValue(false));
|
||||
$backend->expects($this->once())
|
||||
->method('loginName2UserName')
|
||||
->willReturn(false);
|
||||
$backend->expects($this->never())
|
||||
->method('loginName2UserName');
|
||||
|
||||
$manager = new \OC\User\Manager($this->config);
|
||||
$manager->registerBackend($backend);
|
||||
|
|
Loading…
Reference in New Issue