2

I have two problems with @nuxt/auth, the first is that $auth.loggedIn is not reacting to change, I have the below code for my app and when I login or logout I have to chage the route in order for the header to reacte and change state (hide or show login/register and user info) below is my code for template.

<userdown  @logout="$auth.logout()" v-if="$auth.loggedIn"/>
<div v-else>
  <nuxt-link :to="localePath('/login')" class="text-white mx-4">
    {{$t("links.login")}}
  </nuxt-link>
  <nuxt-link :to="localePath('/register')" class="text-white mx-4">
    {{$t("links.register")}}
  </nuxt-link>
</div>

The second one is that the redirect is not working automatically (example when login it should redirect to home page but nothing happen)

auth: {
    strategies: {
      local: {
        token: {
          property: 'token'
        },
        user: {
          property: 'user'
        },
        endpoints: {
          login: { url: '/api/auth/login', method: 'post' },
          logout: { url: '/api/auth/logout', method: 'post' },
          user: { url: '/api/auth/user', method: 'get' }
        }
      }
    },
    redirect: {
      login: '/login',
      logout: '/',
      callback: '/login',
      home: '/'
    }
}

Ana Houa
  • 901
  • 1
  • 8
  • 19

1 Answers1

1

I've encountered the same issue in production. Locally, everything works as expected. Anyways, I've ended up using:

v-show="$store.state.auth.loggedIn"
notrexbias
  • 81
  • 3