react-firebase-authentication icon indicating copy to clipboard operation
react-firebase-authentication copied to clipboard

Localstorage is not updated after SignUp

Open ludovicjamet opened this issue 3 years ago • 0 comments

I removed the email verification. My submit function is like :

onSubmit = event => { const { username, email, passwordOne, isAdmin } = this.state; const roles = {};

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.

ludovicjamet avatar Dec 09 '20 10:12 ludovicjamet