Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localstorage is not updated after SignUp #43

Open
ludovicjamet opened this issue Dec 9, 2020 · 0 comments
Open

Localstorage is not updated after SignUp #43

ludovicjamet opened this issue Dec 9, 2020 · 0 comments

Comments

@ludovicjamet
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant