if (isAdmin) {
roles[ROLES.ADMIN] = ROLES.ADMIN;
}
this.props.firebase
.doCreateUserWithEmailAndPassword(email, passwordOne)
.then(authUser => {
// Retrieve data from Firestore
const appConfig = await this.firestore
.doc('config/app')
.get();
// Create a user in your Firebase realtime database
return this.props.firebase.user(authUser.user.uid).set({
username,
email,
roles,
appConfig
});
})
.then(() => {
this.setState({ ...INITIAL_STATE });
this.props.history.push(ROUTES.HOME);
})
.catch(error => {
if (error.code === ERROR_CODE_ACCOUNT_EXISTS) {
error.message = ERROR_MSG_ACCOUNT_EXISTS;
}
this.setState({ error });
});
event.preventDefault();
};
I have a console.log of authUser value in localStorage when HOME is mounted, it doesn't contains my appConfig value. I had to refresh the page to have the proper value.
I removed the email verification. My submit function is like :
onSubmit = event => { const { username, email, passwordOne, isAdmin } = this.state; const roles = {};
};
I have a console.log of authUser value in localStorage when HOME is mounted, it doesn't contains my appConfig value. I had to refresh the page to have the proper value.