Skip to content

Commit

Permalink
Fix #309 (#512)
Browse files Browse the repository at this point in the history
  • Loading branch information
Widcket authored Oct 7, 2021
1 parent 3c2839b commit 5ef6a7b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/helpers/with-page-auth-required.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,14 @@ import { withPageAuthRequired as withPageAuthRequiredCSR } from '../frontend';
*
* @category Server
*/
export type GetServerSidePropsResultWithSession = GetServerSidePropsResult<{
user?: Claims | null;
[key: string]: any;
}>;
export type GetServerSidePropsResultWithSession<P = any> = GetServerSidePropsResult<P & { user?: Claims | null }>;

/**
* A page route that has been augmented with {@link WithPageAuthRequired}
*
* @category Server
*/
export type PageRoute = (cts: GetServerSidePropsContext) => Promise<GetServerSidePropsResultWithSession>;
export type PageRoute<P> = (cts: GetServerSidePropsContext) => Promise<GetServerSidePropsResultWithSession<P>>;

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

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

0 comments on commit 5ef6a7b

Please sign in to comment.