nuxt-community / auth-module

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

Logout not working properly #1748

Open trandaison opened 2 years ago

trandaison commented 2 years ago

Version

module: 5.0.0-1624817847.21691f1 nuxt: 2.15.7

Nuxt configuration

I want to set the cookie for mydomain.com and m.mydomain.com, so the value of domain option is '.mydomain.com'

auth: {
  cookie: {
    options: {
      domain: '.mydomain.com',
    },
  },
},

mode:

Reproduction

n/a

What is expected?

When I perform logout, I cannot access secret pages, it should redirect to login page instead.

What is actually happening?

When I perform logout, it redirect to login page but after that, I still can access secret pages.

Steps to reproduce

Just set the domain option as above to allow domain and its subdomains log in. Perform logout and enter any secret page.

Additional information

I found that the removeUniversal function calls removeCookie function without any options. It should have passed the options object in order to set the cookie properly. https://github.dev/nuxt-community/auth-module/blob/c9880dc28f/src/schemes/local.ts

  removeUniversal(key: string): void {
    this.removeState(key)
    this.removeLocalStorage(key)
    this.removeCookie(key)
  }

  removeCookie(key: string, options?: { prefix?: string }): void {
    this.setCookie(key, undefined, options)
  }