This commit is contained in:
@@ -109,8 +109,8 @@ describe('DashboardAccessGuard route helpers', () => {
|
||||
})
|
||||
|
||||
it('builds sign-in redirects with public dashboard return paths', () => {
|
||||
expect(buildSignInRedirect('/reservations')).toBe('/sign-in?redirect=%2Fdashboard%2Freservations')
|
||||
expect(buildSignInRedirect('/dashboard/fleet')).toBe('/sign-in?redirect=%2Fdashboard%2Ffleet')
|
||||
expect(buildSignInRedirect('/reservations')).toBe('/dashboard/sign-in?redirect=%2Fdashboard%2Freservations')
|
||||
expect(buildSignInRedirect('/dashboard/fleet')).toBe('/dashboard/sign-in?redirect=%2Fdashboard%2Ffleet')
|
||||
})
|
||||
|
||||
it('treats subscription as an owner-only recovery route independent of menu registration', () => {
|
||||
|
||||
@@ -93,7 +93,7 @@ export function resolveAccessRedirect(currentPath: string, allowedRoutes: string
|
||||
export function buildSignInRedirect(currentPath: string) {
|
||||
const params = new URLSearchParams()
|
||||
params.set('redirect', toPublicDashboardPath(currentPath))
|
||||
return `/sign-in?${params.toString()}`
|
||||
return `${toPublicDashboardPath('/sign-in')}?${params.toString()}`
|
||||
}
|
||||
|
||||
export default function DashboardAccessGuard({ children }: { children: React.ReactNode }) {
|
||||
@@ -147,7 +147,7 @@ export default function DashboardAccessGuard({ children }: { children: React.Rea
|
||||
|
||||
if (error?.statusCode === 401) {
|
||||
const target = buildSignInRedirect(currentPath)
|
||||
if (target !== currentPath) router.replace(target)
|
||||
if (target !== toPublicDashboardPath(currentPath)) window.location.replace(target)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user