Skip to content

Commit d5f4e72

Browse files
authored
fix: custom dashboard component causes runtime error on create-first-user and account views (#14393)
Fixes #14373 The basic auth test suite fails with a custom dashboard component without this fix. The fix in particular isn't related to the dashboard view, instead this component has its type for `path` as optional, so then it causes this matching function to error.
1 parent 612880d commit d5f4e72

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

packages/next/src/views/Root/isPathMatchingRoute.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ export const isPathMatchingRoute = ({
1313
sensitive?: boolean
1414
strict?: boolean
1515
}) => {
16+
// if no path is defined, we cannot match it so return false early
17+
if (!viewPath) {
18+
return false
19+
}
20+
1621
const keys = []
1722

1823
// run the view path through `pathToRegexp` to resolve any dynamic segments

test/auth-basic/Dashboard.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use client'
2+
import React from 'react'
3+
4+
const MinimalDashboard = () => {
5+
return (
6+
<div style={{ padding: '2rem' }}>
7+
<h1>Minimal Dashboard</h1>
8+
<p>If you can see this, the dashboard component is loading correctly.</p>
9+
</div>
10+
)
11+
}
12+
13+
export default MinimalDashboard

test/auth-basic/config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@ const dirname = path.dirname(filename)
55

66
import { buildConfigWithDefaults } from '../buildConfigWithDefaults.js'
77

8-
// eslint-disable-next-line no-restricted-exports
98
export default buildConfigWithDefaults({
109
admin: {
1110
autoLogin: false,
1211
importMap: {
1312
baseDir: path.resolve(dirname),
1413
},
14+
components: {
15+
views: {
16+
dashboard: { Component: './Dashboard.js' },
17+
},
18+
},
1519
},
1620
typescript: {
1721
outputFile: path.resolve(dirname, 'payload-types.ts'),

test/auth-basic/payload-types.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,13 @@ export interface User {
126126
hash?: string | null;
127127
loginAttempts?: number | null;
128128
lockUntil?: string | null;
129+
sessions?:
130+
| {
131+
id: string;
132+
createdAt?: string | null;
133+
expiresAt: string;
134+
}[]
135+
| null;
129136
password?: string | null;
130137
}
131138
/**
@@ -194,6 +201,13 @@ export interface UsersSelect<T extends boolean = true> {
194201
hash?: T;
195202
loginAttempts?: T;
196203
lockUntil?: T;
204+
sessions?:
205+
| T
206+
| {
207+
id?: T;
208+
createdAt?: T;
209+
expiresAt?: T;
210+
};
197211
}
198212
/**
199213
* This interface was referenced by `Config`'s JSON-Schema

0 commit comments

Comments
 (0)