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.26k stars 162 forks source link

Prevent clear auth data when getSession error #763

Open nvthuong1996 opened 3 months ago

nvthuong1996 commented 3 months ago

Describe the feature

If getSession throws an exception, the backend is most likely at fault: If you clear auth data, all users using the website will have to log in again.

https://github.com/sidebase/nuxt-auth/blob/faa039b72da2c64d9c214f0502dea053c7a4ff84/src/runtime/composables/local/useAuth.ts#L99

How would you implement this?

Only clear the session when the http error code returned from the backend is 401

Additional information

Provider

mbellamyy commented 3 months ago

I'm having the same problem with refresh method.

For example, when the user disconnects their Wifi and periodic refresh is turned on, with the first failed request, the user is logged out because the token data is removed from the state.

The tokens should only be removed in three cases imo:

zoey-kaiser commented 3 months ago

Hi @mbellamyy and @nvthuong1996 👋

I added the rfc label to this issue. I would pull in @phoenix-ru, and we can revisit the current behavior and discuss potential modifications to it!

nvthuong1996 commented 2 months ago

hello @phoenix-ru @zoey-kaiser ! has any update for this issue ?

zoey-kaiser commented 2 months ago

Hi @nvthuong1996 👋

We are currently focusing on finishing up the documentation rewrites, which is why we are currently less actively pushing forward discussions on new issues. Once we have the docs deployed we will revisit this issue (should be pretty soon).

Ulrich-Mbouna commented 1 month ago

Some updates for this error ?