export function registerUserWithEmailAndPassword(nickname, email, password) {
return (dispatch) => {
firebase.auth()
.createUserWithEmailAndPassword(email, password)
.then((user) => {
firebase.database()
.ref('usersChat/' + user._user.uid)
.set({
nickname: nickname,
uid: user._user.uid,
timestamp: Date.now(),
email: email
})
return user
})
.catch((error) => {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
dispatch({
type: types.userRegisterErr,
payload: errorMessage
});
});
}
}
firebase.database().ref('/catalog/' + Need ID ).once('value').then(function(snapshot) {
var data = snapshot.val()
console.log("data",data)
// ...
});
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))
});
}
}