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
I'm using mongoose ^8.11.0 with Auth.js 5.0.0-beta.25
the problem is that is inside the signIn callback I can run this code and work without slightest problem:
const isExist = await getUser(user.email);
console.log("isExist", !!isExist, isExist);
// 2) if not exist then create a new user
if (!isExist) await createNewUser(user);
but that is not the case in session callback where I'm calling the exact same controller:
async session({ session }) {
const currentUser = await getUserOnEdge(session?.user.email);
console.log("currentUser🔴", currentUser);
// 1) adding the role and the id to the session info:
// session.user.id = currentUser._id;
// session.user.userType = currentUser.userType;
return session;
},
it throws mongoose__WEBPACK_IMPORTED_MODULE_0___default(...).connect is not a function
I knew recently -exactly yesterday- that is because mongoose doesn't run on the Edge runtime. ok I got this point but that doesn't make sense at the same time since everything goes well inside signIn callback!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using mongoose ^8.11.0 with Auth.js 5.0.0-beta.25
the problem is that is inside the
signIn
callback I can run this code and work without slightest problem:but that is not the case in
session
callback where I'm calling the exact same controller:it throws
mongoose__WEBPACK_IMPORTED_MODULE_0___default(...).connect is not a function
I knew recently -exactly yesterday- that is because mongoose doesn't run on the Edge runtime. ok I got this point but that doesn't make sense at the same time since everything goes well inside
signIn
callback!Beta Was this translation helpful? Give feedback.
All reactions