fix(next): respect canAccessAdmin when a custom dashboard view is configured#16105
Merged
PatrikKozak merged 2 commits intomainfrom Mar 31, 2026
Merged
Conversation
Contributor
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖
Largest pathsThese visualization shows top 20 largest paths in the bundle.Meta file: packages/next/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_shared.json, Out file: esbuild/exports/shared.js
Meta file: packages/richtext-lexical/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_shared.json, Out file: esbuild/exports/shared_optimized/index.js
DetailsNext to the size is how much the size has increased or decreased compared with the base branch of this PR.
|
GermanJablo
approved these changes
Mar 31, 2026
Contributor
|
🚀 This is included in version v3.81.0 |
milamer
pushed a commit
to milamer/payload
that referenced
this pull request
Apr 20, 2026
…figured (payloadcms#16105) # Overview Ensures `canAccessAdmin` is respected when a custom dashboard view is configured with `path: "/"`. Previously, navigating directly to a collection URL would skip the access check, while navigating to `/admin` worked as expected. ## Key Changes The issue was in `isCustomAdminView` - the `startsWith` check caused any route starting with `/` to match a custom dashboard view, skipping the `canAccessAdmin` redirect for collection and document routes. ## Design Decisions The `isCustomAdminView` bypass exists for custom non-root views (e.g. a public page at `/status`) that handle their own access logic. The root path `/` is a special case - it always goes through the `canAccessAdmin` check regardless of whether it has been overridden. ```typescript // Before — matched every route when dashboard path was '/' if (routeWithoutAdmin.startsWith(view.path)) { return true } // After — root path always enforces canAccessAdmin; non-root uses safe exact/prefix match if ( view.path && view.path !== '/' && (routeWithoutAdmin === view.path || routeWithoutAdmin.startsWith(view.path + '/')) ) { return true } ``` Fixes payloadcms#16097 --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1213862851143618
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.
Overview
Ensures
canAccessAdminis respected when a custom dashboard view is configured withpath: "/".Previously, navigating directly to a collection URL would skip the access check, while navigating to
/adminworked as expected.Key Changes
The issue was in
isCustomAdminView- thestartsWithcheck caused any route starting with/to match a custom dashboard view, skipping thecanAccessAdminredirect for collection and document routes.Design Decisions
The
isCustomAdminViewbypass exists for custom non-root views (e.g. a public page at/status) that handle their own access logic. The root path/is a special case - it always goes through thecanAccessAdmincheck regardless of whether it has been overridden.Fixes #16097