Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
docs: docblock for getChildForPrincipal class
Signed-off-by: Josh <josh.t.richards@gmail.com>
  • Loading branch information
joshtrichards committed Dec 24, 2025
commit 226d4762771b0c2e4c6c528418ab309f06708a10
13 changes: 11 additions & 2 deletions lib/DAV/RootCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@
use OCA\GroupFolders\Folder\FolderManager;
use OCP\Files\IRootFolder;
use OCP\IUserSession;
use Sabre\DAV\Exception\Forbidden;
use Sabre\DAVACL\AbstractPrincipalCollection;
use Sabre\DAVACL\PrincipalBackend;

/**
* WebDAV root collection for the GroupFolders app.
*
* Provides access to user principal nodes representing each user's group folders home.
*/
class RootCollection extends AbstractPrincipalCollection {
public function __construct(
private readonly IUserSession $userSession,
Expand All @@ -25,17 +31,20 @@ public function __construct(
}

/**
* This method returns a node for a principal.
* Returns a GroupFoldersHome for the principal if the authenticated user matches.
*
* The passed array contains principal information, and is guaranteed to
* at least contain a uri item. Other properties may or may not be
* supplied by the authentication backend.
*
* @throws \Sabre\DAV\Exception\Forbidden If the principal does not match the currently logged-in user.
*/
public function getChildForPrincipal(array $principalInfo): GroupFoldersHome {
[, $name] = \Sabre\Uri\split($principalInfo['uri']);
$user = $this->userSession->getUser();

if (is_null($user) || $name !== $user->getUID()) {
throw new \Sabre\DAV\Exception\Forbidden();
throw new Forbidden('Access to this groupfolders principal is not allowed for this user.');
}

return new GroupFoldersHome($principalInfo, $this->folderManager, $this->rootFolder, $user);
Expand Down