sidebase / nuxt-auth

Authentication built for Nuxt 3! Easily add authentication via OAuth providers, credentials or Email Magic URLs!
https://auth.sidebase.io
MIT License
1.25k stars 162 forks source link

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

Open geofany opened 1 week ago

geofany commented 1 week ago

Environment

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