diff --git a/docs/admin/overview.mdx b/docs/admin/overview.mdx index 4d649b578a..df2f5fea24 100644 --- a/docs/admin/overview.mdx +++ b/docs/admin/overview.mdx @@ -45,7 +45,7 @@ All options for the Admin panel are defined in your base Payload config file. | `components` | Component overrides that affect the entirety of the Admin panel. [More](/docs/admin/components) | | `webpack` | Customize the Webpack config that's used to generate the Admin panel. [More](/docs/admin/webpack) | | `vite` | Customize the Vite config that's used to generate the Admin panel. [More](/docs/admin/vite) | -| `routes` | Replace built-in Admin Panel routes with your own custom routes. I.e. `{ logout: '/custom-logout', inactivity: 'custom-inactivity' }` | +| `routes` | Replace built-in Admin Panel routes with your own custom routes. [More](/docs/admin/overview#custom-admin-panel-routes) | ### The Admin User Collection @@ -88,3 +88,32 @@ Users in the admin panel have access to choosing between light mode and dark mod ### Restricting user access If you would like to restrict which users from a single Collection can access the Admin panel, you can use the `admin` access control function. [Click here](/docs/access-control/overview#admin) to learn more. + +### Custom admin panel routes + +You can configure custom routes in the admin panel for the following routes: + +| Option | Default route | +| ----------------- | ----------------------- | +| `account` | `/account` | +| `createFirstUser` | `/create-first-user` | +| `forgot` | `/forgot` | +| `inactivity` | `/logout-inactivity` | +| `login` | `/login` | +| `logout` | `/logout` | +| `reset` | `/reset` | +| `unauthorized` | `/unauthorized` | + +`payload.config.js`: + +```ts +import { buildConfig } from 'payload/config' + +const config = buildConfig({ + admin: { + routes: { + admin: '/custom-admin-route' + } + }, +}) +``` diff --git a/packages/next/src/utilities/initPage/shared.ts b/packages/next/src/utilities/initPage/shared.ts index c311a3c91c..c09058b8cb 100644 --- a/packages/next/src/utilities/initPage/shared.ts +++ b/packages/next/src/utilities/initPage/shared.ts @@ -8,6 +8,7 @@ const authRouteKeys: (keyof SanitizedConfig['admin']['routes'])[] = [ 'forgot', 'inactivity', 'unauthorized', + 'reset', ] export const isAdminRoute = (route: string, adminRoute: string) => { diff --git a/packages/next/src/views/Document/index.tsx b/packages/next/src/views/Document/index.tsx index cc83a778d9..c5530cacbe 100644 --- a/packages/next/src/views/Document/index.tsx +++ b/packages/next/src/views/Document/index.tsx @@ -1,6 +1,5 @@ import type { EditViewComponent } from 'payload/config' -import type { AdminViewComponent, ServerSideEditViewProps } from 'payload/types' -import type { AdminViewProps } from 'payload/types' +import type { AdminViewComponent, AdminViewProps, ServerSideEditViewProps } from 'payload/types' import { DocumentHeader } from '@payloadcms/ui/elements/DocumentHeader' import { HydrateClientUser } from '@payloadcms/ui/elements/HydrateClientUser' diff --git a/packages/next/src/views/Root/getViewFromConfig.tsx b/packages/next/src/views/Root/getViewFromConfig.tsx index c0c92d329c..5fb2247ca8 100644 --- a/packages/next/src/views/Root/getViewFromConfig.tsx +++ b/packages/next/src/views/Root/getViewFromConfig.tsx @@ -26,7 +26,7 @@ const baseClasses = { } type OneSegmentViews = { - [K in keyof SanitizedConfig['admin']['routes']]: AdminViewComponent + [K in Exclude]: AdminViewComponent } const oneSegmentViews: OneSegmentViews = { diff --git a/packages/payload/src/auth/operations/forgotPassword.ts b/packages/payload/src/auth/operations/forgotPassword.ts index 68ed0784e6..0e20aa23f6 100644 --- a/packages/payload/src/auth/operations/forgotPassword.ts +++ b/packages/payload/src/auth/operations/forgotPassword.ts @@ -108,7 +108,7 @@ export const forgotPasswordOperation = async (incomingArgs: Arguments): Promise< : `${protocol}//${req.headers.get('host')}` let html = `${req.t('authentication:youAreReceivingResetPassword')} - ${serverURL}${config.routes.admin}/reset/${token} + ${serverURL}${config.routes.admin}/${config.admin.routes.reset}/${token} ${req.t('authentication:youDidNotRequestPassword')}` if (typeof collectionConfig.auth.forgotPassword.generateEmailHTML === 'function') { diff --git a/packages/payload/src/config/defaults.ts b/packages/payload/src/config/defaults.ts index e4d1b021f0..eead72c8e9 100644 --- a/packages/payload/src/config/defaults.ts +++ b/packages/payload/src/config/defaults.ts @@ -18,6 +18,7 @@ export const defaults: Omit = { inactivity: '/logout-inactivity', login: '/login', logout: '/logout', + reset: '/reset', unauthorized: '/unauthorized', }, }, diff --git a/packages/payload/src/config/schema.ts b/packages/payload/src/config/schema.ts index 3e49d23c06..8ba704a629 100644 --- a/packages/payload/src/config/schema.ts +++ b/packages/payload/src/config/schema.ts @@ -90,6 +90,7 @@ export default joi.object({ inactivity: joi.string(), login: joi.string(), logout: joi.string(), + reset: joi.string(), unauthorized: joi.string(), }), user: joi.string(), diff --git a/packages/payload/src/config/types.ts b/packages/payload/src/config/types.ts index 137510c2e6..b9ae775492 100644 --- a/packages/payload/src/config/types.ts +++ b/packages/payload/src/config/types.ts @@ -564,6 +564,8 @@ export type Config = { login?: string /** The route for the logout page. */ logout?: string + /** The route for the reset password page. */ + reset?: string /** The route for the unauthorized page. */ unauthorized?: string }