hey so i wanna pass some data from adapterSession to normal session callback but i simply cant because it removes the additional data i pass how can i fix this #12006
Unanswered
achiragaming
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
import NextAuth, { AuthOptions } from "next-auth";
import { PrismaAdapter } from "@auth/prisma-adapter";
import { db } from "@/lib/db";
import authConfig from "@/auth.config";
import { createUserImageByUrl, getAccountByProvider, getLoginAttemptByData, getSessionByToken, getUserByEmail, getUserById } from "@/utils/user";
import { getTwoFactorConfirmationByUserId } from "@/utils/two-factor-confirmation";
import { Adapter, AdapterAccount, AdapterSession, AdapterUser } from "next-auth/adapters";
import { headers } from "next/headers";
import { PrismaClient, User } from "@prisma/client";
import { link } from "fs";
import { getLocationByIp } from "./utils/location";
import { generateToken } from "./lib/tokens";
import { login } from "./actions/auth/login";
import { currentSession } from "./utils/auth";
const customPrismaAdapter = (db: PrismaClient): Adapter => {
const adapter = PrismaAdapter(db) as Adapter;
return {
...adapter,
async updateUser(user: any) {
const existingUser = await getUserByEmail(user.email);
if (!existingUser) throw new Error("User not found");
}
}
export const authOptions: AuthOptions = {
pages: {
signIn: "/auth/login",
error: "/auth/error",
},
secret: process.env.APP_SECRET,
events: {
},
callbacks: {
async signIn({ user, account, profile, }) {
const session = await currentSession();
console.log("Sign in Occured ", session);
},
adapter: customPrismaAdapter(db),
session: { strategy: "database" },
...authConfig,
};
// export const {
// handlers: { GET, POST },
// auth,
// signIn,
// signOut,
// update,
// } = authOptions;
Beta Was this translation helpful? Give feedback.
All reactions