zarpio
zarpio

Reputation: 7348

NuxtJS auth redirect after logout to various paths, if needed

Did Google and read the documentation but no solution found yet, please suggest how to log out the user to different paths if needed.

My scenario/issue

Tried (not working)

this.$auth.logout()
this.$router.push('verify')

I am always being redirected to {domain}/login :-(

Tried > still not working Disabled redirect for logout in nuxt.config.js as follows.

auth: {
  redirect: {
    login: '/signin',
    logout: false,
    home: '/'
  },
}

Upvotes: 1

Views: 1265

Answers (2)

kissu
kissu

Reputation: 46769

In verify.vue

<script>
export default {
  auth: false,
}
</script>

And in your logout file

await this.$auth.logout() // this one needs to be awaited
await this.$router.push('verify')

Upvotes: 3

omerS
omerS

Reputation: 874

Not sure but this may help

According to docs in https://auth.nuxtjs.org/api/options/

Each redirect path can be disabled by setting to false. Also you can disable all redirects by setting redirect to false

What I understand is you can make logout path to false in your plugin and push route wherever you want after logout.

Upvotes: 1

Related Questions