Skip to content

Commit

Permalink
Merge pull request #3091 from nextcloud/publicUsername-performance-fix
Browse files Browse the repository at this point in the history
improve validatePublicUsername() performance
  • Loading branch information
JonathanTreffler committed Sep 27, 2023
2 parents c3c7f20 + 6169251 commit 4f32195
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/Service/SystemService.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ public function validatePublicUsername(string $userName, Share $share): bool {
throw new InvalidUsernameException;
}

// get all groups
foreach (Group::search() as $group) {
// get all groups, that include the requested username in their gid
// or displayname and check if any match completely
foreach (Group::search($userName) as $group) {
if ($userName === strtolower(trim($group->getId()))
|| $userName === strtolower(trim($group->getDisplayName()))) {
throw new InvalidUsernameException;
Expand Down

0 comments on commit 4f32195

Please sign in to comment.