diff --git a/packages/nextjs/src/app-router/server/auth.ts b/packages/nextjs/src/app-router/server/auth.ts index 83e9112f32..4629f0f470 100644 --- a/packages/nextjs/src/app-router/server/auth.ts +++ b/packages/nextjs/src/app-router/server/auth.ts @@ -11,7 +11,8 @@ type AuthSignedIn = AuthObjectWithoutResources< SignedInAuthObject & { /** * @experimental - * This function is experimental as it throws a Nextjs notFound error if user is not authenticated or authorized + * This function is experimental as it throws a Nextjs notFound error if user is not authenticated or authorized. + * In the future we would investigate a way to throw a more appropriate error that clearly describes the not authorized of authenticated status. */ protect: ( params?: @@ -25,7 +26,8 @@ type AuthSignedOut = AuthObjectWithoutResources< SignedOutAuthObject & { /** * @experimental - * This function is experimental as it throws a Nextjs notFound error if user is not authenticated or authorized + * This function is experimental as it throws a Nextjs notFound error if user is not authenticated or authorized. + * In the future we would investigate a way to throw a more appropriate error that clearly describes the not authorized of authenticated status. */ protect: never; } diff --git a/packages/nextjs/src/app-router/server/controlComponents.tsx b/packages/nextjs/src/app-router/server/controlComponents.tsx index 5647d8f199..2177216ff6 100644 --- a/packages/nextjs/src/app-router/server/controlComponents.tsx +++ b/packages/nextjs/src/app-router/server/controlComponents.tsx @@ -18,7 +18,7 @@ export function SignedOut(props: React.PropsWithChildren) { type ProtectServerComponentProps = React.ComponentProps; /** - * Use `` in order to prevent unauthenticated or unauthorized user from accessing the children passed to the component. + * Use `` in order to prevent unauthenticated or unauthorized users from accessing the children passed to the component. * * Examples: * ``` @@ -26,7 +26,7 @@ type ProtectServerComponentProps = React.ComponentProps * has({permission:"a_permission_key"})} /> * has({role:"a_role_key"})} /> - * Unauthorized

}/> + * Unauthorized

} /> * ``` */ export function Protect(props: ProtectServerComponentProps) { @@ -34,7 +34,8 @@ export function Protect(props: ProtectServerComponentProps) { const { has, userId } = auth(); /** - * If neither of the authorization params are passed behave as the `` + * If neither of the authorization params are passed behave as the ``. + * If fallback is present render that instead of rendering nothing. */ if (!restAuthorizedParams.condition && !restAuthorizedParams.role && !restAuthorizedParams.permission) { if (userId) { @@ -58,7 +59,7 @@ export function Protect(props: ProtectServerComponentProps) { } /** - * Fallback to custom ui or null if authorization checks failed + * Fallback to UI provided by user or `null` if authorization checks failed */ return <>{fallback ?? null}; } diff --git a/packages/react/src/components/controlComponents.tsx b/packages/react/src/components/controlComponents.tsx index ffdb1a3fc3..780750a556 100644 --- a/packages/react/src/components/controlComponents.tsx +++ b/packages/react/src/components/controlComponents.tsx @@ -74,7 +74,7 @@ type ProtectProps = React.PropsWithChildren< >; /** - * Use `` in order to prevent unauthenticated or unauthorized user from accessing the children passed to the component. + * Use `` in order to prevent unauthenticated or unauthorized users from accessing the children passed to the component. * * Examples: * ``` @@ -82,14 +82,15 @@ type ProtectProps = React.PropsWithChildren< * * has({permission:"a_permission_key"})} /> * has({role:"a_role_key"})} /> - * Unauthorized

}/> + * Unauthorized

} /> * ``` */ export const Protect = ({ children, fallback, ...restAuthorizedParams }: ProtectProps) => { const { has, userId } = useAuth(); /** - * If neither of the authorization params are passed behave as the `` + * If neither of the authorization params are passed behave as the ``. + * If fallback is present render that instead of rendering nothing. */ if (!restAuthorizedParams.condition && !restAuthorizedParams.role && !restAuthorizedParams.permission) { if (userId) { @@ -113,7 +114,7 @@ export const Protect = ({ children, fallback, ...restAuthorizedParams }: Protect } /** - * Fallback to custom ui or null if authorization checks failed + * Fallback to UI provided by user or `null` if authorization checks failed */ return <>{fallback ?? null}; };