fix: allows navigation to reset-pw route, adds customization for route (#6778)
Fixes https://github.com/payloadcms/payload/issues/6745 Fixes the inability to navigate to the reset password route. Adds the ability to customize the route and docs for all customizable admin panel routes.
This commit is contained in:
@@ -8,6 +8,7 @@ const authRouteKeys: (keyof SanitizedConfig['admin']['routes'])[] = [
|
||||
'forgot',
|
||||
'inactivity',
|
||||
'unauthorized',
|
||||
'reset',
|
||||
]
|
||||
|
||||
export const isAdminRoute = (route: string, adminRoute: string) => {
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -26,7 +26,7 @@ const baseClasses = {
|
||||
}
|
||||
|
||||
type OneSegmentViews = {
|
||||
[K in keyof SanitizedConfig['admin']['routes']]: AdminViewComponent
|
||||
[K in Exclude<keyof SanitizedConfig['admin']['routes'], 'reset'>]: AdminViewComponent
|
||||
}
|
||||
|
||||
const oneSegmentViews: OneSegmentViews = {
|
||||
|
||||
@@ -108,7 +108,7 @@ export const forgotPasswordOperation = async (incomingArgs: Arguments): Promise<
|
||||
: `${protocol}//${req.headers.get('host')}`
|
||||
|
||||
let html = `${req.t('authentication:youAreReceivingResetPassword')}
|
||||
<a href="${serverURL}${config.routes.admin}/reset/${token}">${serverURL}${config.routes.admin}/reset/${token}</a>
|
||||
<a href="${serverURL}${config.routes.admin}/${config.admin.routes.reset}/${token}">${serverURL}${config.routes.admin}/${config.admin.routes.reset}/${token}</a>
|
||||
${req.t('authentication:youDidNotRequestPassword')}`
|
||||
|
||||
if (typeof collectionConfig.auth.forgotPassword.generateEmailHTML === 'function') {
|
||||
|
||||
@@ -18,6 +18,7 @@ export const defaults: Omit<Config, 'db' | 'editor' | 'secret'> = {
|
||||
inactivity: '/logout-inactivity',
|
||||
login: '/login',
|
||||
logout: '/logout',
|
||||
reset: '/reset',
|
||||
unauthorized: '/unauthorized',
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user