Skip to content

IONOS: fix: do not offer document creation to public share visitors - #14

Merged
bromiesTM merged 1 commit into
ionos-stable33from
mk/fix/HDNEXT-1967-gate-template-creators-for-guests
Aug 4, 2026
Merged

IONOS: fix: do not offer document creation to public share visitors#14
bromiesTM merged 1 commit into
ionos-stable33from
mk/fix/HDNEXT-1967-gate-template-creators-for-guests

Conversation

@printminion-co

@printminion-co printminion-co commented Aug 3, 2026

Copy link
Copy Markdown

Part of HDNEXT-1967 — porting features from the v30 release to ionos-stable33 / ionos-dev-v33.

Blocks: IONOS-Productivity/nc-server#300 — that PR carries the apps-external/richdocuments gitlink bump pointing at this branch's commit, so this needs to merge first.

Summary

deab95d3e added the userCanEdit() gate to RegisterTemplateFileCreatorListener, but the guard is skipped when there is no logged-in user:

$user = $this->permissionManager->loggedInUser();
$userCanCreate = $this->permissionManager->isEnabledForUser($user) && $this->permissionManager->userCanEdit($user);
if ($user && !$userCanCreate) {   // <-- $user is null on a public share
    return;
}

loggedInUser() returns null on a public share link, so the early return never happens and all four Collabora creation entries get registered for anonymous visitors. DefaultPublicShareTemplateProvider calls listCreators() when rendering a public share, so this reaches the public share page.

Both group checks already report false without a user, so dropping the $user && condition is enough. Behaviour for logged-in users is unchanged.

Why this is needed for the v33 line

ionos-dev-v30 blocked this in src/public.js by only registering the legacy OCA.Files.NewFileMenu plugin when the current user was in edit_groups — for a guest getCurrentUser() is null, so the menu stayed away:

f1db58f79 IONOS: fix: for shares allow document creation only for users that can edit

That plugin and src/view/NewFileMenu.js no longer exist in the NC33 line, so the same product behaviour is restored where creation entries now come from.

How it was verified

Reproduced against the dev instance before fixing — with capabilities present and no user session, 4 creators were registered while userCanEdit() reported false.

  • New test testHandleDoesNotRegisterForPublicShareVisitor — confirmed it fails without the one-line fix (not a vacuous test) and passes with it
  • Full unit suite green: 89 tests, 208 assertions

Checklist

  • Code is properly formatted
  • Tests are included
  • Screenshots before/after for front-end changes — n/a, backend gate only
  • Documentation not required

deab95d added the userCanEdit() gate to this listener, but the guard is
skipped when there is no logged-in user:

    if ($user && !$userCanCreate) {

loggedInUser() returns null on a public share link, so $user is null, the
early return never happens and all four Collabora creation entries get
registered for anonymous visitors. DefaultPublicShareTemplateProvider
calls listCreators() when rendering a public share, so this reaches the
public share page. Reproduced against the dev instance: with
capabilities present and no user session, 4 creators were registered
while userCanEdit() reported false.

ionos-dev-v30 blocked this in src/public.js by only registering the
legacy OCA.Files.NewFileMenu plugin when the current user was in
edit_groups - for a guest getCurrentUser() is null, so the menu stayed
away. That plugin and src/view/NewFileMenu.js no longer exist in the NC33
line, so restore the same product behaviour where creation entries now
come from: gate the anonymous case here as well.

Both group checks already report false without a user, so dropping the
$user condition is enough. Behaviour for logged-in users is unchanged.

Ported from ionos-dev-v30 richdocuments:
  f1db58f IONOS: fix: for shares allow document creation only for users
            that can edit
@bromiesTM
bromiesTM merged commit 61fd579 into ionos-stable33 Aug 4, 2026
32 of 47 checks passed
@bromiesTM
bromiesTM deleted the mk/fix/HDNEXT-1967-gate-template-creators-for-guests branch August 4, 2026 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants