Next.js Discord

Discord Forum

signout event nextauth

Unanswered
American black bear posted this in #help-forum
Open in Discord
American black bearOP
Hello, was the signout event removed? If not, how can I use it? Because typescript seems to think its not a valid callback?

export const authOptions: NextAuthOptions = {
  callbacks: {
    async signOut() {
      console.log(1);
    },
    async signIn({ user, account, profile }) {
      const discordProfile = profile as DiscordProfile;
      if (!user.id) throw new Error('User ID is null!');
      const u = await prisma.account.findFirst({
        where: {
          userId: user.id,
        },
      });
      if (u && u.id) {
        await prisma.account.update({
          where: {
            id: u.id,
          },
          data: {
            access_token: account?.access_token,
            refresh_token: account?.refresh_token,
            user: {
              update: {
                name: `${
                  discordProfile.username || discordProfile?.global_name
                }`,
                image: discordProfile?.image,
                email: discordProfile?.email,
              },
            },
          },
        });
      }

      return true;
    },

2 Replies

American black bearOP