Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AuthenticatedRoute: Add back lost type #8989

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions packages/router/src/AuthenticatedRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@ import { Redirect } from './links'
import { routes } from './router'
import { useRouterState } from './router-context'

export function AuthenticatedRoute(props: any) {
interface AuthenticatedRouteProps {
children: React.ReactNode
roles?: string | string[]
unauthenticated?: keyof typeof routes
whileLoadingAuth?: () => React.ReactElement | null
private?: boolean
}

export function AuthenticatedRoute(props: AuthenticatedRouteProps) {
const {
private: privateSet,
private: isPrivate,
unauthenticated,
roles,
whileLoadingAuth,
Expand All @@ -24,7 +32,7 @@ export function AuthenticatedRoute(props: any) {
}, [isAuthenticated, roles, hasRole])

// Make sure `wrappers` is always an array with at least one wrapper component
if (privateSet && unauthorized()) {
if (isPrivate && unauthorized()) {
if (!unauthenticated) {
throw new Error(
'Private Sets need to specify what route to redirect unauthorized ' +
Expand Down