mirror of
https://github.com/xavidop/cardex.git
synced 2026-08-28 23:01:22 +00:00
fix: from reading from firestore
This commit is contained in:
+3
-2
@@ -2,9 +2,10 @@ rules_version = '2';
|
||||
|
||||
service cloud.firestore {
|
||||
match /databases/{database}/documents {
|
||||
// Temporarily allow all authenticated users to test auth
|
||||
// Allow all operations in emulator for development
|
||||
// This will only apply when using Firebase emulators
|
||||
match /{document=**} {
|
||||
allow read, write: if request.auth != null;
|
||||
allow read, write: if true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ try {
|
||||
storage = getStorage(app);
|
||||
|
||||
// Connect to emulators in development - do this immediately after getting auth/db instances
|
||||
if (process.env.NODE_ENV === 'development' && !emulatorsConnected && typeof window !== 'undefined') {
|
||||
if (process.env.NODE_ENV === 'development' && !emulatorsConnected) {
|
||||
try {
|
||||
connectAuthEmulator(auth, 'http://localhost:9099', { disableWarnings: true });
|
||||
connectFirestoreEmulator(db, 'localhost', 8080);
|
||||
|
||||
@@ -354,6 +354,22 @@ export const getUserProfile = async (userId: string): Promise<UserProfile | null
|
||||
if (userSnap.exists()) {
|
||||
return userSnap.data() as UserProfile;
|
||||
}
|
||||
|
||||
// Create a basic user profile if it doesn't exist
|
||||
console.log(`User profile not found for ${userId}, creating basic profile...`);
|
||||
const basicProfile: Partial<UserProfile> = {
|
||||
email: '',
|
||||
displayName: 'Anonymous User',
|
||||
};
|
||||
|
||||
await createOrUpdateUserProfile(userId, basicProfile);
|
||||
|
||||
// Return the newly created profile
|
||||
const newUserSnap = await getDoc(userRef);
|
||||
if (newUserSnap.exists()) {
|
||||
return newUserSnap.data() as UserProfile;
|
||||
}
|
||||
|
||||
return null;
|
||||
} catch (error) {
|
||||
console.error('Error getting user profile:', error);
|
||||
|
||||
Reference in New Issue
Block a user