Skip to content

Commit 5ef6a7b

Browse files
authored
Fix #309 (#512)
1 parent 3c2839b commit 5ef6a7b

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/helpers/with-page-auth-required.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,14 @@ import { withPageAuthRequired as withPageAuthRequiredCSR } from '../frontend';
2525
*
2626
* @category Server
2727
*/
28-
export type GetServerSidePropsResultWithSession = GetServerSidePropsResult<{
29-
user?: Claims | null;
30-
[key: string]: any;
31-
}>;
28+
export type GetServerSidePropsResultWithSession<P = any> = GetServerSidePropsResult<P & { user?: Claims | null }>;
3229

3330
/**
3431
* A page route that has been augmented with {@link WithPageAuthRequired}
3532
*
3633
* @category Server
3734
*/
38-
export type PageRoute = (cts: GetServerSidePropsContext) => Promise<GetServerSidePropsResultWithSession>;
35+
export type PageRoute<P> = (cts: GetServerSidePropsContext) => Promise<GetServerSidePropsResultWithSession<P>>;
3936

4037
/**
4138
* If you have a custom returnTo url you should specify it in `returnTo`.
@@ -63,7 +60,10 @@ export type PageRoute = (cts: GetServerSidePropsContext) => Promise<GetServerSid
6360
*
6461
* @category Server
6562
*/
66-
export type WithPageAuthRequiredOptions = { getServerSideProps?: GetServerSideProps; returnTo?: string };
63+
export type WithPageAuthRequiredOptions<P = any> = {
64+
getServerSideProps?: GetServerSideProps<P>;
65+
returnTo?: string;
66+
};
6767

6868
/**
6969
* Wrap your `getServerSideProps` with this method to make sure the user is authenticated before visiting the page.
@@ -85,7 +85,7 @@ export type WithPageAuthRequiredOptions = { getServerSideProps?: GetServerSidePr
8585
* @category Server
8686
*/
8787
export type WithPageAuthRequired = {
88-
(opts?: WithPageAuthRequiredOptions): PageRoute;
88+
<P>(opts?: WithPageAuthRequiredOptions<P>): PageRoute<P>;
8989
<P extends WithPageAuthRequiredProps>(
9090
Component: ComponentType<P>,
9191
options?: WithPageAuthRequiredCSROptions

0 commit comments

Comments
 (0)