Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
373 views
in Technique[技术] by (71.8m points)

@nuxt/auth $auth.loggedIn is not reactive

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: '/'
    }
}


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...