fix: crate or update user

This commit is contained in:
xavidop
2025-07-23 16:57:16 +02:00
parent f1edae23ce
commit c7f4ff9899
3 changed files with 24 additions and 2 deletions
+4 -1
View File
@@ -5,6 +5,7 @@ import { onAuthStateChanged, type User } from 'firebase/auth';
import { auth } from '@/lib/firebase';
import { Loader2 } from 'lucide-react';
import { createOrUpdateUserProfile } from '@/lib/firestore';
import { filterUndefinedValues } from '@/lib/utils';
export interface AuthContextType {
user: User | null;
@@ -24,11 +25,13 @@ export function AuthProvider({ children }: { children: ReactNode }) {
// Create or update user profile when user signs in
if (currentUser) {
try {
await createOrUpdateUserProfile(currentUser.uid, {
const profileData = filterUndefinedValues({
email: currentUser.email || '',
displayName: currentUser.displayName || undefined,
photoURL: currentUser.photoURL || undefined,
});
await createOrUpdateUserProfile(currentUser.uid, profileData);
} catch (error) {
console.error('Error creating/updating user profile:', error);
// Don't block the auth flow for profile creation errors