Skip to content

Commit

Permalink
Update page.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
ArhanAnsari authored Sep 22, 2024
1 parent 2293f21 commit 1432d3f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/auth/signin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"use client";
import { signIn } from "next-auth/react";
import { useRouter } from "next/navigation";
import { useState, useEffect } from "react";
import { useState } from "react";
import { ToastContainer, toast } from "react-toastify";
import { getUserData } from "@/firebaseFunctions"; // Import Firebase function to get user data
import "react-toastify/dist/ReactToastify.css";
Expand All @@ -14,13 +14,15 @@ export default function SignIn() {
const handleSignIn = async () => {
setLoading(true);
try {
const result = await signIn("google");
const result = await signIn("google", { redirect: false }); // Pass { redirect: false }

if (result?.error) {
throw new Error(result.error);
}

// Fetch user data after sign-in
const user = result?.user;
// The session data is typically in a different structure
const user = result?.user; // This may need adjustment based on your NextAuth setup

if (user && user.email) {
const userData = await getUserData(user.email);
if (userData) {
Expand Down

0 comments on commit 1432d3f

Please sign in to comment.