Skip to content

Commit

Permalink
use types in signIn callback
Browse files Browse the repository at this point in the history
  • Loading branch information
minhd-vu committed Feb 25, 2024
1 parent e84903c commit 054c609
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import prisma from "@/lib/prisma";
import NextAuth, { NextAuthOptions } from "next-auth";
import NextAuth, { NextAuthOptions, User } from "next-auth";
import { AdapterUser } from "next-auth/adapters";
import GithubProvider from "next-auth/providers/github";
import GoogleProvider from "next-auth/providers/google";

Expand All @@ -16,7 +17,11 @@ const options: NextAuthOptions = {
}),
],
callbacks: {
async signIn({ user }: { user: any }) {
async signIn({ user }: { user: User | AdapterUser }) {
if (!user.email || !user.name) {
return false;
}

try {
let player = await prisma.user.findUnique({
where: {
Expand All @@ -39,21 +44,6 @@ const options: NextAuthOptions = {

return true;
},
async session({ session }: { session: any }) {
if (session.user?.email) {
const user = await prisma.user.findUnique({
where: {
email: session.user.email,
},
include: {
party: true,
},
});
session.user = user;
}

return session;
},
},
};

Expand Down

0 comments on commit 054c609

Please sign in to comment.