Skip to content

Commit

Permalink
Update route.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
ArhanAnsari authored Sep 22, 2024
1 parent a0c2faa commit 60c63ff
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ const authOptions = {
}

// Reference to the user's document in Firestore
const userDocRef = adminDb.collection("users").doc(userEmail);
const userDoc = await userDocRef.get();
const userDocRef = doc(adminDb.collection("users"), userEmail);
const userDoc = await getDoc(userDocRef);

if (userDoc.exists) {
if (userDoc.exists()) {
// User already exists, fetch plan and request count
const userData = userDoc.data();
console.log("User Plan:", userData?.plan);
Expand All @@ -37,7 +37,7 @@ const authOptions = {
plan: "free", // Default plan
requestCount: 0, // Default request count
};
await userDocRef.set(newUser);
await setDoc(userDocRef, newUser);
console.log("New user created with Free plan and 0 request count.");
}

Expand Down

0 comments on commit 60c63ff

Please sign in to comment.