Skip to content

Pass a parameter through from the signIn function on the front end to signIn callback in auth.ts. #12192

Discussion options

You must be logged in to vote

Hey, I may found a solution for your problem. I think you should store the necessary user information directly in the jwt. I created a auth.ts file which may be working.

// auth.ts
export const authOptions: NextAuthOptions = {
  adapter: PrismaAdapter(prisma),
  
  callbacks: {
    jwt: async ({ token, user, account }) => {
      if (user) {
        token.userId = user.id;
        token.providers = user.providers || [];
      }
      
      if (account) {
        token.currentProvider = {
          provider: account.provider,
          providerAccountId: account.providerAccountId
        };
      }
      
      return token;
    },

    session: async ({ session, token }) => {
      if (t…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by TheOneBenBailey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants