Skip to content

Commit

Permalink
Use email settings in DAV search
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <louis@chmn.me>
  • Loading branch information
artonge authored and backportbot-nextcloud[bot] committed Jun 23, 2022
1 parent f536789 commit fc834d4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion apps/dav/lib/Connector/Sabre/Principal.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ protected function searchUserPrincipals(array $searchProperties, $test = 'allof'
$limitEnumerationPhone = $this->shareManager->limitEnumerationToPhone();
$allowEnumerationFullMatch = $this->shareManager->allowEnumerationFullMatch();
$ignoreSecondDisplayName = $this->shareManager->ignoreSecondDisplayName();
$matchEmail = $this->shareManager->matchEmail();

// If sharing is restricted to group members only,
// return only members that have groups in common
Expand Down Expand Up @@ -294,7 +295,7 @@ protected function searchUserPrincipals(array $searchProperties, $test = 'allof'
switch ($prop) {
case '{http://sabredav.org/ns}email-address':
if (!$allowEnumeration) {
if ($allowEnumerationFullMatch) {
if ($allowEnumerationFullMatch && $matchEmail) {
$users = $this->userManager->getByEmail($value);
} else {
$users = [];
Expand Down
4 changes: 4 additions & 0 deletions apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,10 @@ public function testSearchPrincipalWithEnumerationDisabledEmail() {
->method('allowEnumerationFullMatch')
->willReturn(true);

$this->shareManager->expects($this->once())
->method('matchEmail')
->willReturn(true);

$user2 = $this->createMock(IUser::class);
$user2->method('getUID')->willReturn('user2');
$user2->method('getDisplayName')->willReturn('User 2');
Expand Down

0 comments on commit fc834d4

Please sign in to comment.