Accessing this.$auth in vuejs right after loginWithRedirect()

I am using vuejs with the auth0 wrapper as outlined here:

I am having trouble accessing the this.$auth object immediately after a successful login.

I am using vuex and I want to update some state related to the user, assuming the login was successful.

After the redirect to the callback URL, if I try to execute code at the mounted() hook, I can access this.$auth and the Vue object details show an isAuthenticated attribute === true.

HOWEVER, if I try to access this.$auth.isAuthenticated within the same hook, in the same place, it comes back as false.

I can only access the correct value of this.$auth.isAuthenticated on some event after all elements have loaded. So for example, on @click of some element, the value returns true, without any other changes.

Hoping someone could explain how this.$auth object works.

1 Like

I did this:

    setTimeout(
      function() {
        this.$auth.loginWithRedirect();
      }.bind(this),
      1
    );