nuxt-community / auth-module

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

Dispatch action after sign in #1698

Open augnustin opened 2 years ago

augnustin commented 2 years ago

Once the user is logged in, I need to fetch some data from the server kind of like the nuxtServerInit strategy.

I created a $auth plugin which calls nuxtClientInit like detailed there.

It works if the page load happens when the user is already logged in.

But how can I make sure the action is also dispatched after sign in?

I could call it from my login.vue method, but it feels hacky and not the proper way to do this and the app wouldn't wait for the call to finish before rendering the next page which is something I need.

How can I intercept the very moment after login happens? Maybe I would have a chance with a middleware or something?

Cheers