Updating the JWT on new-user
Unanswered
Cape lion posted this in #help-forum
Cape lionOP
Im switching to the JWT strategy and i have some logic that runs on my new user page
How do i add the team to the JWT?
export const authOptions: NextAuthOptions = {
debug: env.VERCEL_ENV === "development" || env.VERCEL_ENV === "preview",
session: {
strategy: "jwt",
},
callbacks: {
async jwt({ token, user }) {
if (user) token.user = user as Session["user"];
return token;
},
async session({ session, user, token }) {
return token;
},
async signIn({ user, account, profile, email, credentials }) {
const params = { user, account, profile, email, credentials };
return await onSignin(params);
},
},
adapter: PrismaAdapter(prisma),
providers: [
],
pages: {
signIn: "/",
newUser: "/auth/new-user",
},
};
export default NextAuth(authOptions);
/// new-user
...
const { team, user } = await createNewTeamForNewUser({
teamName: session.user.email as string,
userId: session.user.id,
}); // gets created in the database but not added to the JWT
return redirectTo(`/dashboard/${team?.slug}/welcome`);How do i add the team to the JWT?