How to make “onAuthStateChanged” wait to “currentUser.updateProfile” to finish?

I have a problem registering users in my Vue app… When a user register, I want to fire updateProfile to add more user data, and after that, in the onAuthStateChanged in my main.js save all that user data in vuex to use across my app, but the onAuthStateChanged excutes before the updateProfile , so in vuex displayName and photoURL are undefined.

How can I make the onAuthStateChanged wait to updateProfile to finish?

I have this function in my Register.vue component:

register() {
      firebase
        .auth()
        .createUserWithEmailAndPassword(this.email, this.password)
        .then(user => {
          firebase
            .auth()
            .currentUser.updateProfile({
              displayName: this.displayName,
              photoURL: this.photoURL
            })
            .then(() => {
              db.collection("users")
                .doc(user.user.uid)
                .set({
                  email: this.email,
                  displayName: this.displayName,
                  realName: this.realName,
                  photoURL: this.photoURL
                })
                .then(() => {
                  console.log(user);
                  this.$router.replace("/");
                })
                .catch(err => {
                  this.errorMessage = err.message;
                });
            })
            .catch(err => {
              this.errorMessage = err.message;
            });
        })
        .catch(function(error) {
          // Handle Errors here.
          var errorCode = error.code;
          var errorMessage = error.message;
          if (errorCode == "auth/weak-password") {
            alert("The password is too weak.");
          } else {
            alert(errorMessage);
          }
          console.log(error);
        });
    }

And have this in my main.js:

let app = "";

firebase.auth().onAuthStateChanged((user) => {
  store.dispatch("fetchUser", user);
  if (!app) {
    new Vue({
      router,
      store,
      render: (h) => h(App),
    }).$mount("#app");
  }
});