-1

react-redux-firebase isn't populating user profle in firebase reducer even after a successful signIn width auth.signInWithEmailAndPassword method and data exist users/${uid}.As I'm storing data in firestore so I've configured react-redux-firebase as:

const reduxFirebaseConfig = {
  userProfile: 'users',
  attachAuthIsReady: true,
  useFirestoreForProfile: true,
  updateProfileOnLogin: false
};

Reducer in redux-dev-tool:

firebase > profile {isLoaded: false, isEmpty: true}. 

Note: Working with react-native so using it's firebase library (React-Native-firebase). Everything work perfectly except user profile in firebase reducer.

Robert
  • 4,805
  • 16
  • 34
  • 46
Ahsan Khan
  • 21
  • 3

2 Answers2

1

Question was added a long time ago, but i found the sollution: This only works for the users you created using your app form. Not the initial user you created inside Firebase as that one does not exists inside the "users" collection.

PatrykBuniX
  • 150
  • 4
0

Have you specified the profileFactory key for your reduxFirebaseConfig?

My reduxFirebaseConfig looks like:

const reduxFirebaseConfig = {
  userProfile: 'users',
  useFirestoreForProfile: true,
  enableRedirectHandling: false,
  resetBeforeLogin: false,
  profileFactory
};

and my profile factory looks like:

const profileFactory = (userData, profileData) => {
  let {
    email,
    firstName,
    lastName,
    companyId,
    department,
    division
  } = profileData;
  firstName = startCase(firstName);
  lastName = startCase(lastName);
  const username = `${firstName} ${lastName}`;
  const initials = `${firstName[0]}${lastName[0]}`;
  return {
    email: email,
    firstName,
    lastName,
    username,
    initials,
    department,
    division: division || '',
    companies: { [companyId]: true }
  };
};
krewllobster
  • 305
  • 3
  • 7