fix: let sharing links into a CMS-mode community - #3680
Open
isTravis wants to merge 1 commit into
Open
Conversation
CMS mode was admitting members only, so a Sharing/View URL like `/pub/<slug>/draft?access=<hash>` returned "We can't find that community" to the very people it is for. Authors could not reach their own proofs without first being added as members of the community, which puts an account-provisioning step in front of every review. The cause was ordering, not policy: the gate ran before `getScope`, which is the only place an `?access=` hash is resolved, so the hash was never consulted. The community 404'd first. That also explains why changing the discussion permissions had no effect -- this is a community-existence gate, not a permission one. So the CMS gate now runs after `getScope` and keys on `activePermissions.canView`, which is precisely "insider": a member of the community, collection or pub, a superadmin, or the holder of an access hash matching something in this URL. Public permissions do not raise it, and neither does a pub being released (a released pub is visible via `releases.length`, a separate path), so the community stays invisible to the public. One pub's hash does not unlock another, and the community home -- which no hash can match -- stays gated. The spam gate keeps its old position and its members-only rule. A spam-flagged community has no way to opt a visitor back in, so it needs nothing from the scope; only CMS mode does. Two consequences worth noting: - Requests that are turned away now run `getScope` before 404ing. It already ran for every request that got through. - On a custom-domain community the domain redirect now precedes the gate, so a subdomain request redirects and is gated at the destination. The banner in App.tsx keyed on merely being logged in, which would now show "only Members can see this page" to an author who arrived by link; it keys on community membership instead. Tests: `isCmsGated` covers the gate decision. A DB-backed scopeGet test pins the load-bearing assumption -- that `canView` is false for anonymous and logged-in non-member visitors to a released pub carrying the most permissive public permissions, false for a wrong hash and for another pub's hash, and true for a member and for view/comment hash holders.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CMS mode was admitting members only (as designed), so a Sharing/View URL like
/pub/<slug>/draft?access=<hash>returned "We can't find that community" to the very people it is for. Authors could not reach their own proofs without first being added as members of the community, which puts an account-provisioning step in front of every review.The cause was ordering, not policy: the gate ran before
getScope, which is the only place an?access=hash is resolved, so the hash was never consulted. The community 404'd first. That also explains why changing the discussion permissions had no effect -- this is a community-existence gate, not a permission one.So the CMS gate now runs after
getScopeand keys onactivePermissions.canView, which is precisely "insider": a member of the community, collection or pub, a superadmin, or the holder of an access hash matching something in this URL. Public permissions do not raise it, and neither does a pub being released (a released pub is visible viareleases.length, a separate path), so the community stays invisible to the public.The spam gate keeps its old position and its members-only rule. A spam-flagged community has no way to opt a visitor back in, so it needs nothing from the scope; only CMS mode does.
Two consequences worth noting:
getScopebefore 404ing. It already ran for every request that got through.The banner in App.tsx keyed on merely being logged in, which would now show "only Members can see this page" to an author who arrived by link; it keys on community membership instead.
Tests:
isCmsGatedcovers the gate decision. A DB-backed scopeGet test pins the load-bearing assumption -- thatcanViewis false for anonymous and logged-in non-member visitors to a released pub carrying the most permissive public permissions, false for a wrong hash and for another pub's hash, and true for a member and for view/comment hash holders.