Session is not being created when logged in

Solution:
Callbacks | NextAuth.js
Callbacks are asynchronous functions you can use to control what happens when an action is performed.
Jump to solution
11 Replies
gmoxy
gmoxy15mo ago
you have to make the session with adapter.createSession() not sure if ur making it somewhere else but its not here
gave_one
gave_one15mo ago
I don’t understand I am creating a custom credentials to sign the user is being created but the session is not created when signed in Where would I put this adapter.createSession() Please explain @brick
gmoxy
gmoxy15mo ago
in ur callbacks make one where you set the cookie next auth will call it once it needs to make a session
gave_one
gave_one15mo ago
gave_one
gave_one15mo ago
are you talking about this? @brick sorry for the long wait this is the callbacks
callbacks: {

jwt: ({ token, account } ) =>{
if (account) {
token.accessToken = account.access_token
}
return token

},
session: ({ session, user }) => ({
...session,
user: {
...session.user,
id: user.id,
},
}),
},
callbacks: {

jwt: ({ token, account } ) =>{
if (account) {
token.accessToken = account.access_token
}
return token

},
session: ({ session, user }) => ({
...session,
user: {
...session.user,
id: user.id,
},
}),
},
@brick
gmoxy
gmoxy15mo ago
yes, probably would look something like this depends on what you want
async signIn({ user, account, profile, email, credentials}){
await adapter.createSession({
// values to make ur session ie userid, sessionToke etc..
});

// set cookie
return;
}
async signIn({ user, account, profile, email, credentials}){
await adapter.createSession({
// values to make ur session ie userid, sessionToke etc..
});

// set cookie
return;
}
gave_one
gave_one15mo ago
the adapter.createSession where does it come from? I don't understand. What time do you wrong? I followed the following resources.
gave_one
gave_one15mo ago
NextAuth.js
Authentication for Next.js
gave_one
gave_one15mo ago
Build SaaS with Ethan
YouTube
Set up Next-Auth with Next.js and Prisma with this ultimate guide!
This is the ULTIMATE guide for setting up Next Auth with the credential provider and Prisma. Check out my other video for setting up Prisma and then dive in to hook it all up. Learn how to protect routes, get session information, and configure everything so you can fully use Next Auth. ALL IN THE APP DIRECTORY! Let's go! 🔖 Chapters 🔖 00:00 ...
gave_one
gave_one15mo ago
@brick this is the updated code with the signing https://paste.gg/p/anonymous/16f42850c39f4d2d8a9d71df278f8f4e
Solution
gmoxy
gmoxy15mo ago
Callbacks | NextAuth.js
Callbacks are asynchronous functions you can use to control what happens when an action is performed.
Want results from more Discord servers?
Add your server