E
E
evg_962018-02-26 07:37:51
React
evg_96, 2018-02-26 07:37:51

How to add users to firebase?

Current state:
5a938dc6e7e49708015913.png
The auth module stores the user under which they entered the site.
It is added in the following way:

case SIGN_IN_SUCCESS: {
  return state
    .set("loading", false)
    .set("user", action.payload.user) // добавление пользователя в состояние из firebase
    .set("error", null);
}

How now to make it so that in the state, for example, in the users / people module, store all users who have registered? (We need to be able to display a list of all users in the future, and add data to the user, such as name, phone, etc., since initially he only has email). And you need to somehow organize it all as a collection of users in firebase
Please tell me, otherwise I don’t know how to move on, stupor

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Aleksandrovich, 2018-02-26
@evg_96

I worked with firebase and I remember doing this

const authenticateWithEmailAndPassword = (email, password) => {
    // console.log('authenticateWithEmailAndPassword',email, password)
    return dispatch => {
        dispatch({type: types.START_LOGIN});
        firebaseAuth.signInWithEmailAndPassword(email, password)
            .then(result => {
               //Здесь вы ложите email и пасс  пользователя  в users/people/id данного пользователя 
                dispatch(signInEmailPasswordSuccess(result))
            })
            .catch(error => {
                dispatch(signInError(error))
            });
    }
}

And at the right moment you can take all users from users/people/

M
Maxim, 2018-02-26
@maxfarseer

Now how to make it so that in the state, for example, in the users / people module, store all users who have registered

See how to get all users in firebase and at the right time, execute a request for them.
Or is there more of a question about finding the right method in the firebase API?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question