Skip to content

Localstorage is not updated after SignUp #43

Open
@ludovicjamet

Description

@ludovicjamet

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions