feat!: custom views are now public by default and fixed some issues with notFound page (#8820)
This PR aims to fix a few issues with the notFound page and custom views so it matches v2 behaviour: - Non authorised users should always be redirected to the login page regardless if not found or valid URL - Previously notFound would render for non users too potentially exposing valid but protected routes and creating a confusing workflow as the UI was being rendered as well - Custom views are now public by default - in our `admin` test suite, the `/admin/public-custom-view` is accessible to non users but `/admin/public-custom-view/protected-nested-view` is not unless the checkbox is true in the Settings global, there's e2e coverage for this - Fixes https://github.com/payloadcms/payload/issues/8716
This commit is contained in:
@@ -12,6 +12,7 @@ import { getPayloadHMR } from '../getPayloadHMR.js'
|
||||
import { initReq } from '../initReq.js'
|
||||
import { getRouteInfo } from './handleAdminPage.js'
|
||||
import { handleAuthRedirect } from './handleAuthRedirect.js'
|
||||
import { isCustomAdminView } from './isCustomAdminView.js'
|
||||
import { isPublicAdminRoute } from './shared.js'
|
||||
|
||||
export const initPage = async ({
|
||||
@@ -133,7 +134,8 @@ export const initPage = async ({
|
||||
|
||||
if (
|
||||
!permissions.canAccessAdmin &&
|
||||
!isPublicAdminRoute({ adminRoute, config: payload.config, route })
|
||||
!isPublicAdminRoute({ adminRoute, config: payload.config, route }) &&
|
||||
!isCustomAdminView({ adminRoute, config: payload.config, route })
|
||||
) {
|
||||
redirectTo = handleAuthRedirect({
|
||||
config: payload.config,
|
||||
|
||||
Reference in New Issue
Block a user