注销后 NuxtJS 身份验证重定向到各种路径,如果需要

NuxtJS auth redirect after logout to various paths, if needed

做了 Google 并阅读了文档,但尚未找到解决方案,如果需要,请建议如何将用户注销到不同的路径。

我的scenario/issue

已尝试(无效)

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

我总是被重定向到 {domain}/login :-(

已尝试 > 仍然无效nuxt.config.js 中禁用注销重定向,如下所示。

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

不确定,但这可能有帮助

根据 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

据我了解,您可以在插件中将注销路径设置为 false,并在注销后将路由推送到任何您想要的地方。

verify.vue

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

并且在您的注销文件中

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