sidebase / nuxt-auth

🔐 Nuxt user authentication and sessions via authjs (next-auth), local and refresh providers. nuxt-auth wraps NextAuth.js to offer the reliability & convenience of a 12k star library to the nuxt 3 ecosystem with a native developer experience (DX)
https://sidebase.io/nuxt-auth/
MIT License
1.13k stars 134 forks source link

Can we globally set required: true for getSession on enableRefreshPeriodically and enableRefreshOnWindowFocus #700

Open iamdagy opened 4 months ago

iamdagy commented 4 months ago

Describe the feature

in local provider I have in nuxt.config.ts:

        session: {
          enableRefreshOnWindowFocus: true,
          enableRefreshPeriodically: 3600000
        },

it would be nice if it were possible to add :

        session: {
          required:true,
          callback: '/login' ,
          enableRefreshOnWindowFocus: true,
          enableRefreshPeriodically: 3600000
        },

so when it gets a session response without session /error.. it will redirect immediatly to the callback url

How would you implement this?

im not sure.. but i think adding and option for visibilityHandler or for enableRefreshOnWindowFocus and enableRefreshPeriodically.

Additional information

Provider

phoenix-ru commented 3 months ago

@iamdagy Do you mean an option to automatically redirect to /login page when session invalidates?