From aed9757409c62939f915ccb714e0dca67ecdb6d1 Mon Sep 17 00:00:00 2001 From: Alex Johansson Date: Wed, 18 Aug 2021 14:15:22 +0200 Subject: [PATCH] fix bad auth commit (#487) --- lib/auth.ts | 6 +++--- pages/api/auth/[...nextauth].tsx | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/auth.ts b/lib/auth.ts index 8cd2a341..a2b32d9c 100644 --- a/lib/auth.ts +++ b/lib/auth.ts @@ -17,13 +17,13 @@ type CalendsoSessionUser = DefaultSessionUser & { id: number; username: string; }; -interface Session extends DefaultSession { +export interface Session extends DefaultSession { user?: CalendsoSessionUser; } -export async function getSession(options: GetSessionOptions): Promise { +export async function getSession(options: GetSessionOptions): Promise { const session = await getSessionInner(options); // that these are equal are ensured in `[...nextauth]`'s callback - return session as CalendsoSession; + return session as Session | null; } diff --git a/pages/api/auth/[...nextauth].tsx b/pages/api/auth/[...nextauth].tsx index 3e5ec5fc..e7755ef8 100644 --- a/pages/api/auth/[...nextauth].tsx +++ b/pages/api/auth/[...nextauth].tsx @@ -1,7 +1,7 @@ import NextAuth from "next-auth"; import Providers from "next-auth/providers"; import prisma from "../../../lib/prisma"; -import { CalendsoSession, verifyPassword } from "../../../lib/auth"; +import { Session, verifyPassword } from "../../../lib/auth"; export default NextAuth({ session: { @@ -59,7 +59,7 @@ export default NextAuth({ return token; }, async session(session, token) { - const calendsoSession: CalendsoSession = { + const calendsoSession: Session = { ...session, user: { ...session.user,