Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save LucasMagnum/ca38729f31b28fb1777dad4be90c205d to your computer and use it in GitHub Desktop.
Save LucasMagnum/ca38729f31b28fb1777dad4be90c205d to your computer and use it in GitHub Desktop.
const signInWithGoogle = async () => {
setLoading(true);
try {
await signInWithPopup(auth, googleProvider);
toast({
title: "Signed In",
description: "Successfully signed in with Google.",
});
} catch (error) {
console.error("Google Sign-In Error:", error);
toast({
title: "Sign-In Error",
description: "Could not sign in with Google. Please try again.",
variant: "destructive",
});
setUser(null); // Ensure user is null on error
} finally {
// onAuthStateChanged will set loading to false once user state is confirmed
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment