Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to trigger signOut when refresh got no response without reload page #917

Open
geofany opened this issue Sep 20, 2024 · 1 comment
Open
Labels
bug A bug that needs to be resolved pending An issue waiting for triage

Comments

@geofany
Copy link

geofany commented Sep 20, 2024

Environment

  • Operating System: Darwin
  • Node Version: v20.17.0
  • Nuxt Version: 3.13.1
  • CLI Version: 3.13.1
  • Nitro Version: 2.9.7
  • Package Manager: [email protected]
  • Builder: -
  • User Config: auth, build, compatibilityDate, css, devtools, i18n, imports, modules, runtimeConfig, vite
  • Runtime Modules: @nuxtjs/[email protected], @pinia/[email protected], pinia-plugin-persistedstate/nuxt, @sidebase/[email protected], ()
  • Build Modules: -

Reproduction

Describe the bug

auth: {
    baseURL: `${process.env.BASE_URL}/api/v1/authentication/`,
    globalAppMiddleware: true,
    provider: {
      type: "local",
      token: {
        maxAgeInSeconds: 60 * 60 * 24,
        signInResponseTokenPointer: "/data/access_token",
      },
      pages: {
        login: "/",
      },
      refresh: {
        isEnabled: true,
        refreshOnlyToken: false,
        endpoint: {
          path: "refresh",
          method: "post",
        },
        token: {
          signInResponseRefreshTokenPointer: "/data/refresh_token",
          refreshRequestTokenPointer: "/refreshToken",
        },
      },
      endpoints: {
        signIn: { path: "login", method: "post" },
        signOut: { path: "logout", method: "post" },
        signUp: { path: "register", method: "post" },
        getSession: { path: "validate", method: "post" },
      },
    },
  },

how can i trigger signOut automatically when refresh got no response. without need to Reload the Page
i already use watcher to check token, and status
but not work

watch(status, (newVal) => {
  if(newVal === 'unauthenticated') {
    console.log("Logout")
  } else {
    console.log(newVal)
  }
})
Screenshot 2024-09-20 at 13 39 47

Additional context

No response

Logs

No response

@geofany geofany added bug A bug that needs to be resolved pending An issue waiting for triage labels Sep 20, 2024
@fooddeveloper
Copy link

fooddeveloper commented Oct 24, 2024

Are there any alternative ways to handle this bug ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug that needs to be resolved pending An issue waiting for triage
Projects
None yet
Development

No branches or pull requests

2 participants