nuxt-alt / auth

An alternative module to @nuxtjs/auth
https://nuxt-alt-auth.vercel.app/
MIT License
113 stars 20 forks source link

fix: only react to loggedIn changes #16

Closed hendrikheil closed 1 year ago

hendrikheil commented 1 year ago

Currently the loggedIn watcher reacts to any SET event on the store. This causes weird bugs when you have a scheme like cookie that always resets itself on login. The following event timeline is true without this fix:

  1. loggedIn = false
  2. User calls auth.login()
  3. reset happens, loggedIn = false
  4. watcher kicks in and redirects to logout
  5. user login takes place
  6. user is set, loggedIn = true
  7. watcher kicks in and redirects to home

With this PR the following would be true:

  1. loggedIn = false
  2. User calls auth.login()
  3. reset happens, loggedIn = false
  4. user login happens
  5. user is set, loggedIn = true
  6. watcher kicks in and redirects to home