You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
to export type AfterCallback = ( req: NextApiRequest, res: NextApiResponse, session: Session, state?: { [key: string]: any } ) => Promise<Session | undefined> | Session | undefined;
otherwise we need to //@ts-ignore an async afterCallback that terminates instead of returning a session promise
Reproduction
constafterCallback=async(req: NextApiRequest,res: NextApiResponse,session: Session,state?: {[key: string]: any})=>{if(session.user.isAdmin){awaitdoSomeAsyncStuff();returnsession;}res.status(401).end('User is not admin');};
throws: Type 'Promise<Session | undefined>' is not assignable to type 'Session | Promise | undefined'.
Type 'Promise<Session | undefined>' is not assignable to type 'Promise'
SDK version
2.0
Next.js version
13
Node.js version
16
The text was updated successfully, but these errors were encountered:
Checklist
Description
In version 2.0 the lib now supports terminating requests in afterCallback.
The contract is that afterCallback should not return session and instead do a res.end()
the problem is that the signature of afterCallback should change from:
export type AfterCallback = ( req: NextApiRequest, res: NextApiResponse, session: Session, state?: { [key: string]: any } ) => Promise<Session> | Session | undefined;
to
export type AfterCallback = ( req: NextApiRequest, res: NextApiResponse, session: Session, state?: { [key: string]: any } ) => Promise<Session | undefined> | Session | undefined;
otherwise we need to //@ts-ignore an async afterCallback that terminates instead of returning a session promise
Reproduction
throws: Type 'Promise<Session | undefined>' is not assignable to type 'Session | Promise | undefined'.
Type 'Promise<Session | undefined>' is not assignable to type 'Promise'
SDK version
2.0
Next.js version
13
Node.js version
16
The text was updated successfully, but these errors were encountered: