nuxt-community / auth-module

Zero-boilerplate authentication support for Nuxt 2
https://auth.nuxtjs.org
MIT License
1.93k stars 927 forks source link

BUG, I log in with a user, if I refresh it it takes the last user who logged in #1877

Open vitorhugosg opened 5 months ago

vitorhugosg commented 5 months ago

Version

module: 5.0.0-1648802546.c9880dc nuxt: "``^2.15.8

Nuxt configuration

mode:

Nuxt configuration

auth: { redirect: { login: "/auth/login", },

strategies: {
  local: {
    endpoints: {
      login: {
        url: "v1/auth/login",
        method: "post",
        propertyName: "token",
      },
      logout: {
        url: "v1/auth/logout",
        method: "post",
      },
      user: {
        url: "v1/auth/me",
        method: "get",
        propertyName: "user",
      },
    },
  },
},

},

What is expected?

When I log in to my platform I have a normal login, but when I log out and log in again, I already appear logged in with the last user who logged in, I've already tried doing everything, removing the cloudflare cache, removing all caches possible. I took nuxt hydration, I'm desperate because my app is in production

When I press ctrl+r and it gives getMe, it works normally, but there are times when it doesn't show /me, when it doesn't show /me it crashes with the last login made on the platform

Algúem já teve esse problema?

vitorhugosg commented 5 months ago

image image Putting more evidence here, when I log in with a person, I think the cookie is being saved in the ssr, so when I log in with another person and press CTRL+R I appear logged in with another person, in this case the last person who logged in , I did this test locally, so it only gets the accounts I logged in to, but if I have it on the server, it gets the last person who logged in, I managed to fix it, but it's giving MANY errors, still setting cookies:false, but all Every time I press ctrl+R it logs out.

And some pages give a bug, because it can't read localStorage on the client side.

Does anyone know if this has happened to you using nuxt2 auth? Would it be one of remodeling my entire login system? I have a similar login on other platforms, I never had this problem...