Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

add jwt callback to next-auth

Marc Seitz7042800d9c51
diff --git a/pages/api/auth/[...nextauth].ts b/pages/api/auth/[...nextauth].ts
index d4058597..d68b95be 100644
--- a/pages/api/auth/[...nextauth].ts
+++ b/pages/api/auth/[...nextauth].ts
@@ -29,6 +29,15 @@ export const authOptions: NextAuthOptions = {
},
},
callbacks: {
+ jwt: async ({ token, user }) => {
+ if (!token.email) {
+ return {};
+ }
+ if (user) {
+ token.user = user;
+ }
+ return token;
+ },
session: async ({ session, token }) => {
(session.user as CustomUser) = {
// @ts-ignore